summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp5
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/addressee.cpp1
3 files changed, 5 insertions, 3 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 6e8d027..3ec0795 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -352,208 +352,209 @@ bool AddressBook::save( Ticket *ticket )
352{ 352{
353 kdDebug(5700) << "AddressBook::save()"<< endl; 353 kdDebug(5700) << "AddressBook::save()"<< endl;
354 354
355 if ( ticket->resource() ) { 355 if ( ticket->resource() ) {
356 deleteRemovedAddressees(); 356 deleteRemovedAddressees();
357 return ticket->resource()->save( ticket ); 357 return ticket->resource()->save( ticket );
358 } 358 }
359 359
360 return false; 360 return false;
361} 361}
362bool AddressBook::saveAB() 362bool AddressBook::saveAB()
363{ 363{
364 bool ok = true; 364 bool ok = true;
365 365
366 deleteRemovedAddressees(); 366 deleteRemovedAddressees();
367 367
368 KRES::Manager<Resource>::ActiveIterator it; 368 KRES::Manager<Resource>::ActiveIterator it;
369 KRES::Manager<Resource> *manager = d->mManager; 369 KRES::Manager<Resource> *manager = d->mManager;
370 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 370 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
371 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 371 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
372 Ticket *ticket = requestSaveTicket( *it ); 372 Ticket *ticket = requestSaveTicket( *it );
373// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 373// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
374 if ( !ticket ) { 374 if ( !ticket ) {
375 error( i18n( "Unable to save to resource '%1'. It is locked." ) 375 error( i18n( "Unable to save to resource '%1'. It is locked." )
376 .arg( (*it)->resourceName() ) ); 376 .arg( (*it)->resourceName() ) );
377 return false; 377 return false;
378 } 378 }
379 379
380 //if ( !save( ticket ) ) 380 //if ( !save( ticket ) )
381 if ( ticket->resource() ) { 381 if ( ticket->resource() ) {
382 if ( ! ticket->resource()->save( ticket ) ) 382 if ( ! ticket->resource()->save( ticket ) )
383 ok = false; 383 ok = false;
384 } else 384 } else
385 ok = false; 385 ok = false;
386 386
387 } 387 }
388 } 388 }
389 return ok; 389 return ok;
390} 390}
391 391
392AddressBook::Iterator AddressBook::begin() 392AddressBook::Iterator AddressBook::begin()
393{ 393{
394 Iterator it = Iterator(); 394 Iterator it = Iterator();
395 it.d->mIt = d->mAddressees.begin(); 395 it.d->mIt = d->mAddressees.begin();
396 return it; 396 return it;
397} 397}
398 398
399AddressBook::ConstIterator AddressBook::begin() const 399AddressBook::ConstIterator AddressBook::begin() const
400{ 400{
401 ConstIterator it = ConstIterator(); 401 ConstIterator it = ConstIterator();
402 it.d->mIt = d->mAddressees.begin(); 402 it.d->mIt = d->mAddressees.begin();
403 return it; 403 return it;
404} 404}
405 405
406AddressBook::Iterator AddressBook::end() 406AddressBook::Iterator AddressBook::end()
407{ 407{
408 Iterator it = Iterator(); 408 Iterator it = Iterator();
409 it.d->mIt = d->mAddressees.end(); 409 it.d->mIt = d->mAddressees.end();
410 return it; 410 return it;
411} 411}
412 412
413AddressBook::ConstIterator AddressBook::end() const 413AddressBook::ConstIterator AddressBook::end() const
414{ 414{
415 ConstIterator it = ConstIterator(); 415 ConstIterator it = ConstIterator();
416 it.d->mIt = d->mAddressees.end(); 416 it.d->mIt = d->mAddressees.end();
417 return it; 417 return it;
418} 418}
419 419
420void AddressBook::clear() 420void AddressBook::clear()
421{ 421{
422 d->mAddressees.clear(); 422 d->mAddressees.clear();
423} 423}
424 424
425Ticket *AddressBook::requestSaveTicket( Resource *resource ) 425Ticket *AddressBook::requestSaveTicket( Resource *resource )
426{ 426{
427 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 427 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
428 428
429 if ( !resource ) 429 if ( !resource )
430 { 430 {
431 qDebug("AddressBook::requestSaveTicket no resource" ); 431 qDebug("AddressBook::requestSaveTicket no resource" );
432 resource = standardResource(); 432 resource = standardResource();
433 } 433 }
434 434
435 KRES::Manager<Resource>::ActiveIterator it; 435 KRES::Manager<Resource>::ActiveIterator it;
436 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 436 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
437 if ( (*it) == resource ) { 437 if ( (*it) == resource ) {
438 if ( (*it)->readOnly() || !(*it)->isOpen() ) 438 if ( (*it)->readOnly() || !(*it)->isOpen() )
439 return 0; 439 return 0;
440 else 440 else
441 return (*it)->requestSaveTicket(); 441 return (*it)->requestSaveTicket();
442 } 442 }
443 } 443 }
444 444
445 return 0; 445 return 0;
446} 446}
447 447
448void AddressBook::insertAddressee( const Addressee &a ) 448void AddressBook::insertAddressee( const Addressee &a, bool setRev )
449{ 449{
450 Addressee::List::Iterator it; 450 Addressee::List::Iterator it;
451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
452 if ( a.uid() == (*it).uid() ) { 452 if ( a.uid() == (*it).uid() ) {
453 bool changed = false; 453 bool changed = false;
454 Addressee addr = a; 454 Addressee addr = a;
455 if ( addr != (*it) ) 455 if ( addr != (*it) )
456 changed = true; 456 changed = true;
457 457
458 (*it) = a; 458 (*it) = a;
459 if ( (*it).resource() == 0 ) 459 if ( (*it).resource() == 0 )
460 (*it).setResource( standardResource() ); 460 (*it).setResource( standardResource() );
461 461
462 if ( changed ) { 462 if ( changed ) {
463 (*it).setRevision( QDateTime::currentDateTime() ); 463 if ( setRev )
464 (*it).setRevision( QDateTime::currentDateTime() );
464 (*it).setChanged( true ); 465 (*it).setChanged( true );
465 } 466 }
466 467
467 return; 468 return;
468 } 469 }
469 } 470 }
470 d->mAddressees.append( a ); 471 d->mAddressees.append( a );
471 Addressee& addr = d->mAddressees.last(); 472 Addressee& addr = d->mAddressees.last();
472 if ( addr.resource() == 0 ) 473 if ( addr.resource() == 0 )
473 addr.setResource( standardResource() ); 474 addr.setResource( standardResource() );
474 475
475 addr.setChanged( true ); 476 addr.setChanged( true );
476} 477}
477 478
478void AddressBook::removeAddressee( const Addressee &a ) 479void AddressBook::removeAddressee( const Addressee &a )
479{ 480{
480 Iterator it; 481 Iterator it;
481 for ( it = begin(); it != end(); ++it ) { 482 for ( it = begin(); it != end(); ++it ) {
482 if ( a.uid() == (*it).uid() ) { 483 if ( a.uid() == (*it).uid() ) {
483 removeAddressee( it ); 484 removeAddressee( it );
484 return; 485 return;
485 } 486 }
486 } 487 }
487} 488}
488 489
489void AddressBook::removeAddressee( const Iterator &it ) 490void AddressBook::removeAddressee( const Iterator &it )
490{ 491{
491 d->mRemovedAddressees.append( (*it) ); 492 d->mRemovedAddressees.append( (*it) );
492 d->mAddressees.remove( it.d->mIt ); 493 d->mAddressees.remove( it.d->mIt );
493} 494}
494 495
495AddressBook::Iterator AddressBook::find( const Addressee &a ) 496AddressBook::Iterator AddressBook::find( const Addressee &a )
496{ 497{
497 Iterator it; 498 Iterator it;
498 for ( it = begin(); it != end(); ++it ) { 499 for ( it = begin(); it != end(); ++it ) {
499 if ( a.uid() == (*it).uid() ) { 500 if ( a.uid() == (*it).uid() ) {
500 return it; 501 return it;
501 } 502 }
502 } 503 }
503 return end(); 504 return end();
504} 505}
505 506
506Addressee AddressBook::findByUid( const QString &uid ) 507Addressee AddressBook::findByUid( const QString &uid )
507{ 508{
508 Iterator it; 509 Iterator it;
509 for ( it = begin(); it != end(); ++it ) { 510 for ( it = begin(); it != end(); ++it ) {
510 if ( uid == (*it).uid() ) { 511 if ( uid == (*it).uid() ) {
511 return *it; 512 return *it;
512 } 513 }
513 } 514 }
514 return Addressee(); 515 return Addressee();
515} 516}
516Addressee::List AddressBook::getExternLastSyncAddressees() 517Addressee::List AddressBook::getExternLastSyncAddressees()
517{ 518{
518 Addressee::List results; 519 Addressee::List results;
519 520
520 Iterator it; 521 Iterator it;
521 for ( it = begin(); it != end(); ++it ) { 522 for ( it = begin(); it != end(); ++it ) {
522 if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) { 523 if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) {
523 if ( (*it).familyName().left(3) == "E: " ) 524 if ( (*it).familyName().left(3) == "E: " )
524 results.append( *it ); 525 results.append( *it );
525 } 526 }
526 } 527 }
527 528
528 return results; 529 return results;
529} 530}
530void AddressBook::resetTempSyncStat() 531void AddressBook::resetTempSyncStat()
531{ 532{
532 Iterator it; 533 Iterator it;
533 for ( it = begin(); it != end(); ++it ) { 534 for ( it = begin(); it != end(); ++it ) {
534 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 535 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
535 } 536 }
536 537
537} 538}
538 539
539QStringList AddressBook:: uidList() 540QStringList AddressBook:: uidList()
540{ 541{
541 QStringList results; 542 QStringList results;
542 Iterator it; 543 Iterator it;
543 for ( it = begin(); it != end(); ++it ) { 544 for ( it = begin(); it != end(); ++it ) {
544 results.append( (*it).uid() ); 545 results.append( (*it).uid() );
545 } 546 }
546 return results; 547 return results;
547} 548}
548 549
549 550
550Addressee::List AddressBook::allAddressees() 551Addressee::List AddressBook::allAddressees()
551{ 552{
552 return d->mAddressees; 553 return d->mAddressees;
553} 554}
554 555
555Addressee::List AddressBook::findByName( const QString &name ) 556Addressee::List AddressBook::findByName( const QString &name )
556{ 557{
557 Addressee::List results; 558 Addressee::List results;
558 559
559 Iterator it; 560 Iterator it;
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 650a638..253de68 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -80,193 +80,193 @@ class AddressBook : public QObject
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 145
146 /** 146 /**
147 Returns a iterator for first entry of address book. 147 Returns a iterator for first entry of address book.
148 */ 148 */
149 Iterator begin(); 149 Iterator begin();
150 150
151 /** 151 /**
152 Returns a const iterator for first entry of address book. 152 Returns a const iterator for first entry of address book.
153 */ 153 */
154 ConstIterator begin() const; 154 ConstIterator begin() const;
155 155
156 /** 156 /**
157 Returns a iterator for first entry of address book. 157 Returns a iterator for first entry of address book.
158 */ 158 */
159 Iterator end(); 159 Iterator end();
160 160
161 /** 161 /**
162 Returns a const iterator for first entry of address book. 162 Returns a const iterator for first entry of address book.
163 */ 163 */
164 ConstIterator end() const; 164 ConstIterator end() const;
165 165
166 /** 166 /**
167 Removes all entries from address book. 167 Removes all entries from address book.
168 */ 168 */
169 void clear(); 169 void clear();
170 170
171 /** 171 /**
172 Insert an Addressee object into address book. If an object with the same 172 Insert an Addressee object into address book. If an object with the same
173 unique id already exists in the address book it it replaced by the new 173 unique id already exists in the address book it it replaced by the new
174 one. If not the new object is appended to the address book. 174 one. If not the new object is appended to the address book.
175 */ 175 */
176 void insertAddressee( const Addressee & ); 176 void insertAddressee( const Addressee &, bool setRev = true );
177 177
178 /** 178 /**
179 Removes entry from the address book. 179 Removes entry from the address book.
180 */ 180 */
181 void removeAddressee( const Addressee & ); 181 void removeAddressee( const Addressee & );
182 182
183 /** 183 /**
184 This is like @ref removeAddressee() just above, with the difference that 184 This is like @ref removeAddressee() just above, with the difference that
185 the first element is a iterator, returned by @ref begin(). 185 the first element is a iterator, returned by @ref begin().
186 */ 186 */
187 void removeAddressee( const Iterator & ); 187 void removeAddressee( const Iterator & );
188 188
189 /** 189 /**
190 Find the specified entry in address book. Returns end(), if the entry 190 Find the specified entry in address book. Returns end(), if the entry
191 couldn't be found. 191 couldn't be found.
192 */ 192 */
193 Iterator find( const Addressee & ); 193 Iterator find( const Addressee & );
194 194
195 /** 195 /**
196 Find the entry specified by an unique id. Returns an empty Addressee 196 Find the entry specified by an unique id. Returns an empty Addressee
197 object, if the address book does not contain an entry with this id. 197 object, if the address book does not contain an entry with this id.
198 */ 198 */
199 Addressee findByUid( const QString & ); 199 Addressee findByUid( const QString & );
200 200
201 201
202 /** 202 /**
203 Returns a list of all addressees in the address book. This list can 203 Returns a list of all addressees in the address book. This list can
204 be sorted with @ref KABC::AddresseeList for example. 204 be sorted with @ref KABC::AddresseeList for example.
205 */ 205 */
206 Addressee::List allAddressees(); 206 Addressee::List allAddressees();
207 207
208 /** 208 /**
209 Find all entries with the specified name in the address book. Returns 209 Find all entries with the specified name in the address book. Returns
210 an empty list, if no entries could be found. 210 an empty list, if no entries could be found.
211 */ 211 */
212 Addressee::List findByName( const QString & ); 212 Addressee::List findByName( const QString & );
213 213
214 /** 214 /**
215 Find all entries with the specified email address in the address book. 215 Find all entries with the specified email address in the address book.
216 Returns an empty list, if no entries could be found. 216 Returns an empty list, if no entries could be found.
217 */ 217 */
218 Addressee::List findByEmail( const QString & ); 218 Addressee::List findByEmail( const QString & );
219 219
220 /** 220 /**
221 Find all entries wich have the specified category in the address book. 221 Find all entries wich have the specified category in the address book.
222 Returns an empty list, if no entries could be found. 222 Returns an empty list, if no entries could be found.
223 */ 223 */
224 Addressee::List findByCategory( const QString & ); 224 Addressee::List findByCategory( const QString & );
225 225
226 /** 226 /**
227 Return a string identifying this addressbook. 227 Return a string identifying this addressbook.
228 */ 228 */
229 virtual QString identifier(); 229 virtual QString identifier();
230 230
231 /** 231 /**
232 Used for debug output. 232 Used for debug output.
233 */ 233 */
234 void dump() const; 234 void dump() const;
235 235
236 void emitAddressBookLocked() { emit addressBookLocked( this ); } 236 void emitAddressBookLocked() { emit addressBookLocked( this ); }
237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
238 void emitAddressBookChanged() { emit addressBookChanged( this ); } 238 void emitAddressBookChanged() { emit addressBookChanged( this ); }
239 239
240 /** 240 /**
241 Return list of all Fields known to the address book which are associated 241 Return list of all Fields known to the address book which are associated
242 with the given field category. 242 with the given field category.
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 */
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index fb32f6e..7f04d8f 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,191 +1,192 @@
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#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46 46
47struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
48{ 48{
49 QString uid; 49 QString uid;
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 KURL url; 69 KURL url;
70 Secrecy secrecy; 70 Secrecy secrecy;
71 Picture logo; 71 Picture logo;
72 Picture photo; 72 Picture photo;
73 Sound sound; 73 Sound sound;
74 Agent agent; 74 Agent agent;
75 QString mExternalId; 75 QString mExternalId;
76 PhoneNumber::List phoneNumbers; 76 PhoneNumber::List phoneNumbers;
77 Address::List addresses; 77 Address::List addresses;
78 Key::List keys; 78 Key::List keys;
79 QStringList emails; 79 QStringList emails;
80 QStringList categories; 80 QStringList categories;
81 QStringList custom; 81 QStringList custom;
82 82
83 Resource *resource; 83 Resource *resource;
84 84
85 bool empty :1; 85 bool empty :1;
86 bool changed :1; 86 bool changed :1;
87}; 87};
88 88
89Addressee::Addressee() 89Addressee::Addressee()
90{ 90{
91 mData = new AddresseeData; 91 mData = new AddresseeData;
92 mData->empty = true; 92 mData->empty = true;
93 mData->changed = false; 93 mData->changed = false;
94 mData->resource = 0; 94 mData->resource = 0;
95 mData->mExternalId = ":"; 95 mData->mExternalId = ":";
96 mData->revision = QDateTime ( QDate( 2004,1,1));
96 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 97 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
97} 98}
98 99
99Addressee::~Addressee() 100Addressee::~Addressee()
100{ 101{
101} 102}
102 103
103Addressee::Addressee( const Addressee &a ) 104Addressee::Addressee( const Addressee &a )
104{ 105{
105 mData = a.mData; 106 mData = a.mData;
106 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 107 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
107} 108}
108 109
109Addressee &Addressee::operator=( const Addressee &a ) 110Addressee &Addressee::operator=( const Addressee &a )
110{ 111{
111 mData = a.mData; 112 mData = a.mData;
112 return (*this); 113 return (*this);
113} 114}
114 115
115Addressee Addressee::copy() 116Addressee Addressee::copy()
116{ 117{
117 Addressee a; 118 Addressee a;
118 *(a.mData) = *mData; 119 *(a.mData) = *mData;
119 return a; 120 return a;
120} 121}
121 122
122void Addressee::detach() 123void Addressee::detach()
123{ 124{
124 if ( mData.count() == 1 ) return; 125 if ( mData.count() == 1 ) return;
125 *this = copy(); 126 *this = copy();
126} 127}
127 128
128bool Addressee::operator==( const Addressee &a ) const 129bool Addressee::operator==( const Addressee &a ) const
129{ 130{
130 if ( uid() != a.uid() ) return false; 131 if ( uid() != a.uid() ) return false;
131 if ( mData->name != a.mData->name ) return false; 132 if ( mData->name != a.mData->name ) return false;
132 if ( mData->formattedName != a.mData->formattedName ) return false; 133 if ( mData->formattedName != a.mData->formattedName ) return false;
133 if ( mData->familyName != a.mData->familyName ) return false; 134 if ( mData->familyName != a.mData->familyName ) return false;
134 if ( mData->givenName != a.mData->givenName ) return false; 135 if ( mData->givenName != a.mData->givenName ) return false;
135 if ( mData->additionalName != a.mData->additionalName ) return false; 136 if ( mData->additionalName != a.mData->additionalName ) return false;
136 if ( mData->prefix != a.mData->prefix ) return false; 137 if ( mData->prefix != a.mData->prefix ) return false;
137 if ( mData->suffix != a.mData->suffix ) return false; 138 if ( mData->suffix != a.mData->suffix ) return false;
138 if ( mData->nickName != a.mData->nickName ) return false; 139 if ( mData->nickName != a.mData->nickName ) return false;
139 if ( mData->birthday != a.mData->birthday ) return false; 140 if ( mData->birthday != a.mData->birthday ) return false;
140 if ( mData->mailer != a.mData->mailer ) return false; 141 if ( mData->mailer != a.mData->mailer ) return false;
141 if ( mData->timeZone != a.mData->timeZone ) return false; 142 if ( mData->timeZone != a.mData->timeZone ) return false;
142 if ( mData->geo != a.mData->geo ) return false; 143 if ( mData->geo != a.mData->geo ) return false;
143 if ( mData->title != a.mData->title ) return false; 144 if ( mData->title != a.mData->title ) return false;
144 if ( mData->role != a.mData->role ) return false; 145 if ( mData->role != a.mData->role ) return false;
145 if ( mData->organization != a.mData->organization ) return false; 146 if ( mData->organization != a.mData->organization ) return false;
146 if ( mData->note != a.mData->note ) return false; 147 if ( mData->note != a.mData->note ) return false;
147 if ( mData->productId != a.mData->productId ) return false; 148 if ( mData->productId != a.mData->productId ) return false;
148 if ( mData->revision != a.mData->revision ) return false; 149 if ( mData->revision != a.mData->revision ) return false;
149 if ( mData->sortString != a.mData->sortString ) return false; 150 if ( mData->sortString != a.mData->sortString ) return false;
150 if ( mData->secrecy != a.mData->secrecy ) return false; 151 if ( mData->secrecy != a.mData->secrecy ) return false;
151 if ( mData->logo != a.mData->logo ) return false; 152 if ( mData->logo != a.mData->logo ) return false;
152 if ( mData->photo != a.mData->photo ) return false; 153 if ( mData->photo != a.mData->photo ) return false;
153 if ( mData->sound != a.mData->sound ) return false; 154 if ( mData->sound != a.mData->sound ) return false;
154 if ( mData->agent != a.mData->agent ) return false; 155 if ( mData->agent != a.mData->agent ) return false;
155 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 156 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
156 ( mData->url != a.mData->url ) ) return false; 157 ( mData->url != a.mData->url ) ) return false;
157 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 158 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
158 if ( mData->addresses != a.mData->addresses ) return false; 159 if ( mData->addresses != a.mData->addresses ) return false;
159 if ( mData->keys != a.mData->keys ) return false; 160 if ( mData->keys != a.mData->keys ) return false;
160 if ( mData->emails != a.mData->emails ) return false; 161 if ( mData->emails != a.mData->emails ) return false;
161 if ( mData->categories != a.mData->categories ) return false; 162 if ( mData->categories != a.mData->categories ) return false;
162 if ( mData->custom != a.mData->custom ) return false; 163 if ( mData->custom != a.mData->custom ) return false;
163 164
164 return true; 165 return true;
165} 166}
166 167
167bool Addressee::operator!=( const Addressee &a ) const 168bool Addressee::operator!=( const Addressee &a ) const
168{ 169{
169 return !( a == *this ); 170 return !( a == *this );
170} 171}
171 172
172bool Addressee::isEmpty() const 173bool Addressee::isEmpty() const
173{ 174{
174 return mData->empty; 175 return mData->empty;
175} 176}
176void Addressee::removeID(const QString &prof) 177void Addressee::removeID(const QString &prof)
177{ 178{
178 detach(); 179 detach();
179 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 180 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
180 181
181} 182}
182void Addressee::setID( const QString & prof , const QString & id ) 183void Addressee::setID( const QString & prof , const QString & id )
183{ 184{
184 detach(); 185 detach();
185 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 186 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
186} 187}
187void Addressee::setTempSyncStat( int id ) 188void Addressee::setTempSyncStat( int id )
188{ 189{
189 mTempSyncStat = id; 190 mTempSyncStat = id;
190} 191}
191int Addressee::tempSyncStat() const 192int Addressee::tempSyncStat() const