-rw-r--r-- | kabc/address.cpp | 13 | ||||
-rw-r--r-- | kabc/address.h | 1 | ||||
-rw-r--r-- | kabc/addressbook.cpp | 133 | ||||
-rw-r--r-- | kabc/addressbook.h | 4 | ||||
-rw-r--r-- | kabc/addressee.cpp | 99 | ||||
-rw-r--r-- | kabc/addressee.h | 2 |
6 files changed, 213 insertions, 39 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp index c820a6c..5ffe511 100644 --- a/kabc/address.cpp +++ b/kabc/address.cpp | |||
@@ -59,64 +59,77 @@ bool Address::operator==( const Address &a ) const | |||
59 | if ( mPostOfficeBox != a.mPostOfficeBox ) return false; | 59 | if ( mPostOfficeBox != a.mPostOfficeBox ) return false; |
60 | if ( mExtended != a.mExtended ) return false; | 60 | if ( mExtended != a.mExtended ) return false; |
61 | if ( mStreet != a.mStreet ) return false; | 61 | if ( mStreet != a.mStreet ) return false; |
62 | if ( mLocality != a.mLocality ) return false; | 62 | if ( mLocality != a.mLocality ) return false; |
63 | if ( mRegion != a.mRegion ) return false; | 63 | if ( mRegion != a.mRegion ) return false; |
64 | if ( mPostalCode != a.mPostalCode ) return false; | 64 | if ( mPostalCode != a.mPostalCode ) return false; |
65 | if ( mCountry != a.mCountry ) return false; | 65 | if ( mCountry != a.mCountry ) return false; |
66 | if ( mLabel != a.mLabel ) return false; | 66 | if ( mLabel != a.mLabel ) return false; |
67 | 67 | ||
68 | return true; | 68 | return true; |
69 | } | 69 | } |
70 | 70 | ||
71 | bool Address::operator!=( const Address &a ) const | 71 | bool Address::operator!=( const Address &a ) const |
72 | { | 72 | { |
73 | return !( a == *this ); | 73 | return !( a == *this ); |
74 | } | 74 | } |
75 | 75 | ||
76 | bool Address::isEmpty() const | 76 | bool Address::isEmpty() const |
77 | { | 77 | { |
78 | if ( mPostOfficeBox.isEmpty() && | 78 | if ( mPostOfficeBox.isEmpty() && |
79 | mExtended.isEmpty() && | 79 | mExtended.isEmpty() && |
80 | mStreet.isEmpty() && | 80 | mStreet.isEmpty() && |
81 | mLocality.isEmpty() && | 81 | mLocality.isEmpty() && |
82 | mRegion.isEmpty() && | 82 | mRegion.isEmpty() && |
83 | mPostalCode.isEmpty() && | 83 | mPostalCode.isEmpty() && |
84 | mCountry.isEmpty() && | 84 | mCountry.isEmpty() && |
85 | mLabel.isEmpty() ) { | 85 | mLabel.isEmpty() ) { |
86 | return true; | 86 | return true; |
87 | } | 87 | } |
88 | return false; | 88 | return false; |
89 | } | 89 | } |
90 | 90 | ||
91 | QStringList Address::asList() | ||
92 | { | ||
93 | QStringList result; | ||
94 | if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox); | ||
95 | if ( ! mExtended.isEmpty())result.append(mExtended); | ||
96 | if ( ! mStreet.isEmpty())result.append(mStreet); | ||
97 | if ( ! mLocality.isEmpty() )result.append(mLocality); | ||
98 | if ( ! mRegion.isEmpty())result.append(mRegion); | ||
99 | if ( ! mPostalCode.isEmpty())result.append(mPostalCode); | ||
100 | if ( ! mCountry.isEmpty())result.append(mCountry); | ||
101 | if ( ! mLabel.isEmpty() )result.append(mLabel); | ||
102 | return result; | ||
103 | } | ||
91 | void Address::clear() | 104 | void Address::clear() |
92 | { | 105 | { |
93 | *this = Address(); | 106 | *this = Address(); |
94 | } | 107 | } |
95 | 108 | ||
96 | void Address::setId( const QString &id ) | 109 | void Address::setId( const QString &id ) |
97 | { | 110 | { |
98 | mEmpty = false; | 111 | mEmpty = false; |
99 | 112 | ||
100 | mId = id; | 113 | mId = id; |
101 | } | 114 | } |
102 | 115 | ||
103 | QString Address::id() const | 116 | QString Address::id() const |
104 | { | 117 | { |
105 | return mId; | 118 | return mId; |
106 | } | 119 | } |
107 | 120 | ||
108 | void Address::setType( int type ) | 121 | void Address::setType( int type ) |
109 | { | 122 | { |
110 | mEmpty = false; | 123 | mEmpty = false; |
111 | 124 | ||
112 | mType = type; | 125 | mType = type; |
113 | } | 126 | } |
114 | 127 | ||
115 | int Address::type() const | 128 | int Address::type() const |
116 | { | 129 | { |
117 | return mType; | 130 | return mType; |
118 | } | 131 | } |
119 | 132 | ||
120 | QString Address::typeLabel() const | 133 | QString Address::typeLabel() const |
121 | { | 134 | { |
122 | QString label; | 135 | QString label; |
diff --git a/kabc/address.h b/kabc/address.h index ad132a7..6b53c7e 100644 --- a/kabc/address.h +++ b/kabc/address.h | |||
@@ -78,64 +78,65 @@ class Address | |||
78 | @li @p Parcel - parcel | 78 | @li @p Parcel - parcel |
79 | @li @p Home - home address | 79 | @li @p Home - home address |
80 | @li @p Work - address at work | 80 | @li @p Work - address at work |
81 | @li @p Pref - preferred address | 81 | @li @p Pref - preferred address |
82 | */ | 82 | */ |
83 | enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, | 83 | enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, |
84 | Pref = 64 }; | 84 | Pref = 64 }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | Constructor that creates an empty Address, which is initialized | 87 | Constructor that creates an empty Address, which is initialized |
88 | with a unique id (see @ref id()). | 88 | with a unique id (see @ref id()). |
89 | */ | 89 | */ |
90 | Address(); | 90 | Address(); |
91 | 91 | ||
92 | /** | 92 | /** |
93 | This is like @ref Address() just above, with the difference | 93 | This is like @ref Address() just above, with the difference |
94 | that you can specify the type. | 94 | that you can specify the type. |
95 | */ | 95 | */ |
96 | Address( int ); | 96 | Address( int ); |
97 | 97 | ||
98 | bool operator==( const Address & ) const; | 98 | bool operator==( const Address & ) const; |
99 | bool operator!=( const Address & ) const; | 99 | bool operator!=( const Address & ) const; |
100 | 100 | ||
101 | /** | 101 | /** |
102 | Returns true, if the address is empty. | 102 | Returns true, if the address is empty. |
103 | */ | 103 | */ |
104 | bool isEmpty() const; | 104 | bool isEmpty() const; |
105 | 105 | ||
106 | /** | 106 | /** |
107 | Clears all entries of the address. | 107 | Clears all entries of the address. |
108 | */ | 108 | */ |
109 | void clear(); | 109 | void clear(); |
110 | QStringList asList(); | ||
110 | 111 | ||
111 | /** | 112 | /** |
112 | Sets the unique id. | 113 | Sets the unique id. |
113 | */ | 114 | */ |
114 | void setId( const QString & ); | 115 | void setId( const QString & ); |
115 | 116 | ||
116 | /* | 117 | /* |
117 | Returns the unique id. | 118 | Returns the unique id. |
118 | */ | 119 | */ |
119 | QString id() const; | 120 | QString id() const; |
120 | 121 | ||
121 | /** | 122 | /** |
122 | Sets the type of address. See enum for definiton of types. | 123 | Sets the type of address. See enum for definiton of types. |
123 | 124 | ||
124 | @param type type, can be a bitwise or of multiple types. | 125 | @param type type, can be a bitwise or of multiple types. |
125 | */ | 126 | */ |
126 | void setType( int type ); | 127 | void setType( int type ); |
127 | 128 | ||
128 | /** | 129 | /** |
129 | Returns the type of address. Can be a bitwise or of multiple types. | 130 | Returns the type of address. Can be a bitwise or of multiple types. |
130 | */ | 131 | */ |
131 | int type() const; | 132 | int type() const; |
132 | 133 | ||
133 | /** | 134 | /** |
134 | Returns a translated string of all types the address has. | 135 | Returns a translated string of all types the address has. |
135 | */ | 136 | */ |
136 | QString typeLabel() const; | 137 | QString typeLabel() const; |
137 | 138 | ||
138 | /** | 139 | /** |
139 | Sets the post office box. | 140 | Sets the post office box. |
140 | */ | 141 | */ |
141 | void setPostOfficeBox( const QString & ); | 142 | void setPostOfficeBox( const QString & ); |
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 16e1653..ec9f893 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -205,64 +205,65 @@ AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | |||
205 | } | 205 | } |
206 | 206 | ||
207 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 207 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
208 | { | 208 | { |
209 | return ( d->mIt == it.d->mIt ); | 209 | return ( d->mIt == it.d->mIt ); |
210 | } | 210 | } |
211 | 211 | ||
212 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 212 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
213 | { | 213 | { |
214 | return ( d->mIt != it.d->mIt ); | 214 | return ( d->mIt != it.d->mIt ); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | AddressBook::AddressBook() | 218 | AddressBook::AddressBook() |
219 | { | 219 | { |
220 | init(0, "contact"); | 220 | init(0, "contact"); |
221 | } | 221 | } |
222 | 222 | ||
223 | AddressBook::AddressBook( const QString &config ) | 223 | AddressBook::AddressBook( const QString &config ) |
224 | { | 224 | { |
225 | init(config, "contact"); | 225 | init(config, "contact"); |
226 | } | 226 | } |
227 | 227 | ||
228 | AddressBook::AddressBook( const QString &config, const QString &family ) | 228 | AddressBook::AddressBook( const QString &config, const QString &family ) |
229 | { | 229 | { |
230 | init(config, family); | 230 | init(config, family); |
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | // the default family is "contact" | 234 | // the default family is "contact" |
235 | void AddressBook::init(const QString &config, const QString &family ) | 235 | void AddressBook::init(const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | blockLSEchange = false; | ||
237 | d = new AddressBookData; | 238 | d = new AddressBookData; |
238 | QString fami = family; | 239 | QString fami = family; |
239 | qDebug("new ab "); | 240 | qDebug("new ab "); |
240 | if (config != 0) { | 241 | if (config != 0) { |
241 | qDebug("config != 0 "); | 242 | qDebug("config != 0 "); |
242 | if ( family == "syncContact" ) { | 243 | if ( family == "syncContact" ) { |
243 | qDebug("creating sync config "); | 244 | qDebug("creating sync config "); |
244 | fami = "contact"; | 245 | fami = "contact"; |
245 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
246 | con->setGroup( "General" ); | 247 | con->setGroup( "General" ); |
247 | con->writeEntry( "ResourceKeys", QString("sync") ); | 248 | con->writeEntry( "ResourceKeys", QString("sync") ); |
248 | con->writeEntry( "Standard", QString("sync") ); | 249 | con->writeEntry( "Standard", QString("sync") ); |
249 | con->setGroup( "Resource_sync" ); | 250 | con->setGroup( "Resource_sync" ); |
250 | con->writeEntry( "FileFormat", QString("vcard") ); | 251 | con->writeEntry( "FileFormat", QString("vcard") ); |
251 | con->writeEntry( "FileName", config ); | 252 | con->writeEntry( "FileName", config ); |
252 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
253 | con->writeEntry( "ResourceName", QString("sync_res") ); | 254 | con->writeEntry( "ResourceName", QString("sync_res") ); |
254 | con->writeEntry( "ResourceType", QString("file") ); | 255 | con->writeEntry( "ResourceType", QString("file") ); |
255 | //con->sync(); | 256 | //con->sync(); |
256 | d->mConfig = con; | 257 | d->mConfig = con; |
257 | } | 258 | } |
258 | else | 259 | else |
259 | d->mConfig = new KConfig( locateLocal("config", config) ); | 260 | d->mConfig = new KConfig( locateLocal("config", config) ); |
260 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 261 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
261 | } | 262 | } |
262 | else { | 263 | else { |
263 | d->mConfig = 0; | 264 | d->mConfig = 0; |
264 | // qDebug("AddressBook::init 1 config=0"); | 265 | // qDebug("AddressBook::init 1 config=0"); |
265 | } | 266 | } |
266 | 267 | ||
267 | //US d->mErrorHandler = 0; | 268 | //US d->mErrorHandler = 0; |
268 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 269 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
@@ -316,64 +317,65 @@ void AddressBook::init(const QString &config, const QString &family ) | |||
316 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 317 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
317 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
318 | "X-ExternalID", "KADDRESSBOOK" ); | 319 | "X-ExternalID", "KADDRESSBOOK" ); |
319 | } | 320 | } |
320 | 321 | ||
321 | AddressBook::~AddressBook() | 322 | AddressBook::~AddressBook() |
322 | { | 323 | { |
323 | delete d->mConfig; d->mConfig = 0; | 324 | delete d->mConfig; d->mConfig = 0; |
324 | delete d->mManager; d->mManager = 0; | 325 | delete d->mManager; d->mManager = 0; |
325 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 326 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
326 | delete d; d = 0; | 327 | delete d; d = 0; |
327 | } | 328 | } |
328 | 329 | ||
329 | bool AddressBook::load() | 330 | bool AddressBook::load() |
330 | { | 331 | { |
331 | 332 | ||
332 | 333 | ||
333 | clear(); | 334 | clear(); |
334 | 335 | ||
335 | KRES::Manager<Resource>::ActiveIterator it; | 336 | KRES::Manager<Resource>::ActiveIterator it; |
336 | bool ok = true; | 337 | bool ok = true; |
337 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 338 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
338 | if ( !(*it)->load() ) { | 339 | if ( !(*it)->load() ) { |
339 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 340 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
340 | ok = false; | 341 | ok = false; |
341 | } | 342 | } |
342 | 343 | ||
343 | // mark all addressees as unchanged | 344 | // mark all addressees as unchanged |
344 | Addressee::List::Iterator addrIt; | 345 | Addressee::List::Iterator addrIt; |
345 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 346 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) |
346 | (*addrIt).setChanged( false ); | 347 | (*addrIt).setChanged( false ); |
347 | 348 | ||
349 | blockLSEchange = true; | ||
348 | return ok; | 350 | return ok; |
349 | } | 351 | } |
350 | 352 | ||
351 | bool AddressBook::save( Ticket *ticket ) | 353 | bool AddressBook::save( Ticket *ticket ) |
352 | { | 354 | { |
353 | kdDebug(5700) << "AddressBook::save()"<< endl; | 355 | kdDebug(5700) << "AddressBook::save()"<< endl; |
354 | 356 | ||
355 | if ( ticket->resource() ) { | 357 | if ( ticket->resource() ) { |
356 | deleteRemovedAddressees(); | 358 | deleteRemovedAddressees(); |
357 | return ticket->resource()->save( ticket ); | 359 | return ticket->resource()->save( ticket ); |
358 | } | 360 | } |
359 | 361 | ||
360 | return false; | 362 | return false; |
361 | } | 363 | } |
362 | bool AddressBook::saveAB() | 364 | bool AddressBook::saveAB() |
363 | { | 365 | { |
364 | bool ok = true; | 366 | bool ok = true; |
365 | 367 | ||
366 | deleteRemovedAddressees(); | 368 | deleteRemovedAddressees(); |
367 | 369 | ||
368 | KRES::Manager<Resource>::ActiveIterator it; | 370 | KRES::Manager<Resource>::ActiveIterator it; |
369 | KRES::Manager<Resource> *manager = d->mManager; | 371 | KRES::Manager<Resource> *manager = d->mManager; |
370 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 372 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
371 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 373 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
372 | Ticket *ticket = requestSaveTicket( *it ); | 374 | Ticket *ticket = requestSaveTicket( *it ); |
373 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 375 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
374 | if ( !ticket ) { | 376 | if ( !ticket ) { |
375 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 377 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
376 | .arg( (*it)->resourceName() ) ); | 378 | .arg( (*it)->resourceName() ) ); |
377 | return false; | 379 | return false; |
378 | } | 380 | } |
379 | 381 | ||
@@ -418,154 +420,213 @@ AddressBook::ConstIterator AddressBook::end() const | |||
418 | } | 420 | } |
419 | 421 | ||
420 | void AddressBook::clear() | 422 | void AddressBook::clear() |
421 | { | 423 | { |
422 | d->mAddressees.clear(); | 424 | d->mAddressees.clear(); |
423 | } | 425 | } |
424 | 426 | ||
425 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 427 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
426 | { | 428 | { |
427 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 429 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
428 | 430 | ||
429 | if ( !resource ) | 431 | if ( !resource ) |
430 | { | 432 | { |
431 | qDebug("AddressBook::requestSaveTicket no resource" ); | 433 | qDebug("AddressBook::requestSaveTicket no resource" ); |
432 | resource = standardResource(); | 434 | resource = standardResource(); |
433 | } | 435 | } |
434 | 436 | ||
435 | KRES::Manager<Resource>::ActiveIterator it; | 437 | KRES::Manager<Resource>::ActiveIterator it; |
436 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 438 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
437 | if ( (*it) == resource ) { | 439 | if ( (*it) == resource ) { |
438 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 440 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
439 | return 0; | 441 | return 0; |
440 | else | 442 | else |
441 | return (*it)->requestSaveTicket(); | 443 | return (*it)->requestSaveTicket(); |
442 | } | 444 | } |
443 | } | 445 | } |
444 | 446 | ||
445 | return 0; | 447 | return 0; |
446 | } | 448 | } |
447 | 449 | ||
448 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | 450 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) |
449 | { | 451 | { |
450 | Addressee::List::Iterator it; | 452 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
451 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 453 | return; |
452 | if ( a.uid() == (*it).uid() ) { | 454 | } |
453 | if ( setRev && (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 455 | bool found = false; |
454 | return; | 456 | Addressee::List::Iterator it; |
455 | } | 457 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
456 | bool changed = false; | 458 | if ( a.uid() == (*it).uid() ) { |
457 | Addressee addr = a; | 459 | |
458 | if ( addr != (*it) ) | 460 | bool changed = false; |
459 | changed = true; | 461 | Addressee addr = a; |
460 | 462 | if ( addr != (*it) ) | |
461 | (*it) = a; | 463 | changed = true; |
462 | if ( (*it).resource() == 0 ) | 464 | |
463 | (*it).setResource( standardResource() ); | 465 | (*it) = a; |
464 | 466 | if ( (*it).resource() == 0 ) | |
465 | if ( changed ) { | 467 | (*it).setResource( standardResource() ); |
466 | if ( setRev ) { | 468 | |
469 | if ( changed ) { | ||
470 | if ( setRev ) { | ||
467 | 471 | ||
468 | // get rid of micro seconds | 472 | // get rid of micro seconds |
469 | QDateTime dt = QDateTime::currentDateTime(); | 473 | QDateTime dt = QDateTime::currentDateTime(); |
470 | QTime t = dt.time(); | 474 | QTime t = dt.time(); |
471 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 475 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
472 | (*it).setRevision( dt ); | 476 | (*it).setRevision( dt ); |
473 | } | 477 | } |
474 | (*it).setChanged( true ); | 478 | (*it).setChanged( true ); |
475 | } | 479 | } |
476 | 480 | ||
477 | return; | 481 | found = true; |
482 | } else { | ||
483 | if ( (*it).uid() == QString("last-syncAddressee-") ) { | ||
484 | QString name = (*it).uid().mid( 19 ); | ||
485 | Addressee b = a; | ||
486 | QString id = b.getID( name ); | ||
487 | if ( ! id.isEmpty() ) { | ||
488 | QString des = (*it).note(); | ||
489 | int startN; | ||
490 | if( (startN = des.find( id ) ) >= 0 ) { | ||
491 | int endN = des.find( ",", startN+1 ); | ||
492 | des = des.left( startN ) + des.mid( endN+1 ); | ||
493 | (*it).setNote( des ); | ||
494 | } | ||
495 | } | ||
496 | } | ||
497 | } | ||
478 | } | 498 | } |
479 | } | 499 | if ( found ) |
480 | d->mAddressees.append( a ); | 500 | return; |
481 | Addressee& addr = d->mAddressees.last(); | 501 | d->mAddressees.append( a ); |
482 | if ( addr.resource() == 0 ) | 502 | Addressee& addr = d->mAddressees.last(); |
483 | addr.setResource( standardResource() ); | 503 | if ( addr.resource() == 0 ) |
504 | addr.setResource( standardResource() ); | ||
484 | 505 | ||
485 | addr.setChanged( true ); | 506 | addr.setChanged( true ); |
486 | } | 507 | } |
487 | 508 | ||
488 | void AddressBook::removeAddressee( const Addressee &a ) | 509 | void AddressBook::removeAddressee( const Addressee &a ) |
489 | { | 510 | { |
490 | Iterator it; | 511 | Iterator it; |
512 | Iterator it2; | ||
513 | bool found = false; | ||
491 | for ( it = begin(); it != end(); ++it ) { | 514 | for ( it = begin(); it != end(); ++it ) { |
492 | if ( a.uid() == (*it).uid() ) { | 515 | if ( a.uid() == (*it).uid() ) { |
493 | removeAddressee( it ); | 516 | found = true; |
494 | return; | 517 | it2 = it; |
518 | } else { | ||
519 | if ( (*it).uid() == QString("last-syncAddressee-") ) { | ||
520 | QString name = (*it).uid().mid( 19 ); | ||
521 | Addressee b = a; | ||
522 | QString id = b.getID( name ); | ||
523 | if ( ! id.isEmpty() ) { | ||
524 | QString des = (*it).note(); | ||
525 | if( des.find( id ) < 0 ) { | ||
526 | des += id + ","; | ||
527 | (*it).setNote( des ); | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | |||
495 | } | 532 | } |
496 | } | 533 | } |
534 | |||
535 | if ( found ) | ||
536 | removeAddressee( it2 ); | ||
537 | |||
538 | } | ||
539 | |||
540 | void AddressBook::removeDeletedAddressees() | ||
541 | { | ||
542 | deleteRemovedAddressees(); | ||
543 | Iterator it = begin(); | ||
544 | Iterator it2 ; | ||
545 | QDateTime dt ( QDate( 2004,1,1) ); | ||
546 | while ( it != end() ) { | ||
547 | (*it).setRevision( dt ); | ||
548 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | ||
549 | it2 = it; | ||
550 | ++it; | ||
551 | removeAddressee( it2 ); | ||
552 | } else | ||
553 | ++it; | ||
554 | } | ||
555 | deleteRemovedAddressees(); | ||
497 | } | 556 | } |
498 | 557 | ||
499 | void AddressBook::removeAddressee( const Iterator &it ) | 558 | void AddressBook::removeAddressee( const Iterator &it ) |
500 | { | 559 | { |
501 | d->mRemovedAddressees.append( (*it) ); | 560 | d->mRemovedAddressees.append( (*it) ); |
502 | d->mAddressees.remove( it.d->mIt ); | 561 | d->mAddressees.remove( it.d->mIt ); |
503 | } | 562 | } |
504 | 563 | ||
505 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 564 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
506 | { | 565 | { |
507 | Iterator it; | 566 | Iterator it; |
508 | for ( it = begin(); it != end(); ++it ) { | 567 | for ( it = begin(); it != end(); ++it ) { |
509 | if ( a.uid() == (*it).uid() ) { | 568 | if ( a.uid() == (*it).uid() ) { |
510 | return it; | 569 | return it; |
511 | } | 570 | } |
512 | } | 571 | } |
513 | return end(); | 572 | return end(); |
514 | } | 573 | } |
515 | 574 | ||
516 | Addressee AddressBook::findByUid( const QString &uid ) | 575 | Addressee AddressBook::findByUid( const QString &uid ) |
517 | { | 576 | { |
518 | Iterator it; | 577 | Iterator it; |
519 | for ( it = begin(); it != end(); ++it ) { | 578 | for ( it = begin(); it != end(); ++it ) { |
520 | if ( uid == (*it).uid() ) { | 579 | if ( uid == (*it).uid() ) { |
521 | return *it; | 580 | return *it; |
522 | } | 581 | } |
523 | } | 582 | } |
524 | return Addressee(); | 583 | return Addressee(); |
525 | } | 584 | } |
585 | #if 0 | ||
526 | Addressee::List AddressBook::getExternLastSyncAddressees() | 586 | Addressee::List AddressBook::getExternLastSyncAddressees() |
527 | { | 587 | { |
528 | Addressee::List results; | 588 | Addressee::List results; |
529 | 589 | ||
530 | Iterator it; | 590 | Iterator it; |
531 | for ( it = begin(); it != end(); ++it ) { | 591 | for ( it = begin(); it != end(); ++it ) { |
532 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 592 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
533 | if ( (*it).familyName().left(3) == "E: " ) | 593 | if ( (*it).familyName().left(4) == "!E: " ) |
534 | results.append( *it ); | 594 | results.append( *it ); |
535 | } | 595 | } |
536 | } | 596 | } |
537 | 597 | ||
538 | return results; | 598 | return results; |
539 | } | 599 | } |
600 | #endif | ||
540 | void AddressBook::resetTempSyncStat() | 601 | void AddressBook::resetTempSyncStat() |
541 | { | 602 | { |
542 | Iterator it; | 603 | Iterator it; |
543 | for ( it = begin(); it != end(); ++it ) { | 604 | for ( it = begin(); it != end(); ++it ) { |
544 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 605 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
545 | } | 606 | } |
546 | 607 | ||
547 | } | 608 | } |
548 | 609 | ||
549 | QStringList AddressBook:: uidList() | 610 | QStringList AddressBook:: uidList() |
550 | { | 611 | { |
551 | QStringList results; | 612 | QStringList results; |
552 | Iterator it; | 613 | Iterator it; |
553 | for ( it = begin(); it != end(); ++it ) { | 614 | for ( it = begin(); it != end(); ++it ) { |
554 | results.append( (*it).uid() ); | 615 | results.append( (*it).uid() ); |
555 | } | 616 | } |
556 | return results; | 617 | return results; |
557 | } | 618 | } |
558 | 619 | ||
559 | 620 | ||
560 | Addressee::List AddressBook::allAddressees() | 621 | Addressee::List AddressBook::allAddressees() |
561 | { | 622 | { |
562 | return d->mAddressees; | 623 | return d->mAddressees; |
563 | 624 | ||
564 | } | 625 | } |
565 | 626 | ||
566 | Addressee::List AddressBook::findByName( const QString &name ) | 627 | Addressee::List AddressBook::findByName( const QString &name ) |
567 | { | 628 | { |
568 | Addressee::List results; | 629 | Addressee::List results; |
569 | 630 | ||
570 | Iterator it; | 631 | Iterator it; |
571 | for ( it = begin(); it != end(); ++it ) { | 632 | for ( it = begin(); it != end(); ++it ) { |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 253de68..2f2678b 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -260,75 +260,77 @@ class AddressBook : public QObject | |||
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 | 291 | // sync stuff |
292 | Addressee::List getExternLastSyncAddressees(); | 292 | //Addressee::List getExternLastSyncAddressees(); |
293 | void resetTempSyncStat(); | 293 | void resetTempSyncStat(); |
294 | QStringList uidList(); | 294 | QStringList uidList(); |
295 | void removeDeletedAddressees(); | ||
295 | 296 | ||
296 | 297 | ||
297 | signals: | 298 | signals: |
298 | /** | 299 | /** |
299 | Emitted, when the address book has changed on disk. | 300 | Emitted, when the address book has changed on disk. |
300 | */ | 301 | */ |
301 | void addressBookChanged( AddressBook * ); | 302 | void addressBookChanged( AddressBook * ); |
302 | 303 | ||
303 | /** | 304 | /** |
304 | Emitted, when the address book has been locked for writing. | 305 | Emitted, when the address book has been locked for writing. |
305 | */ | 306 | */ |
306 | void addressBookLocked( AddressBook * ); | 307 | void addressBookLocked( AddressBook * ); |
307 | 308 | ||
308 | /** | 309 | /** |
309 | Emitted, when the address book has been unlocked. | 310 | Emitted, when the address book has been unlocked. |
310 | */ | 311 | */ |
311 | void addressBookUnlocked( AddressBook * ); | 312 | void addressBookUnlocked( AddressBook * ); |
312 | 313 | ||
313 | protected: | 314 | protected: |
314 | void deleteRemovedAddressees(); | 315 | void deleteRemovedAddressees(); |
315 | void setStandardResource( Resource * ); | 316 | void setStandardResource( Resource * ); |
316 | Resource *standardResource(); | 317 | Resource *standardResource(); |
317 | KRES::Manager<Resource> *resourceManager(); | 318 | KRES::Manager<Resource> *resourceManager(); |
318 | 319 | ||
319 | void init(const QString &config, const QString &family); | 320 | void init(const QString &config, const QString &family); |
320 | 321 | ||
321 | private: | 322 | private: |
322 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 323 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
323 | 324 | ||
324 | 325 | ||
325 | struct AddressBookData; | 326 | struct AddressBookData; |
326 | AddressBookData *d; | 327 | AddressBookData *d; |
328 | bool blockLSEchange; | ||
327 | }; | 329 | }; |
328 | 330 | ||
329 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 331 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
330 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 332 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
331 | 333 | ||
332 | } | 334 | } |
333 | 335 | ||
334 | #endif | 336 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 7f04d8f..0f5d605 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -145,64 +145,160 @@ bool Addressee::operator==( const Addressee &a ) const | |||
145 | if ( mData->role != a.mData->role ) return false; | 145 | if ( mData->role != a.mData->role ) return false; |
146 | if ( mData->organization != a.mData->organization ) return false; | 146 | if ( mData->organization != a.mData->organization ) return false; |
147 | if ( mData->note != a.mData->note ) return false; | 147 | if ( mData->note != a.mData->note ) return false; |
148 | if ( mData->productId != a.mData->productId ) return false; | 148 | if ( mData->productId != a.mData->productId ) return false; |
149 | if ( mData->revision != a.mData->revision ) return false; | 149 | if ( mData->revision != a.mData->revision ) return false; |
150 | if ( mData->sortString != a.mData->sortString ) return false; | 150 | if ( mData->sortString != a.mData->sortString ) return false; |
151 | if ( mData->secrecy != a.mData->secrecy ) return false; | 151 | if ( mData->secrecy != a.mData->secrecy ) return false; |
152 | if ( mData->logo != a.mData->logo ) return false; | 152 | if ( mData->logo != a.mData->logo ) return false; |
153 | if ( mData->photo != a.mData->photo ) return false; | 153 | if ( mData->photo != a.mData->photo ) return false; |
154 | if ( mData->sound != a.mData->sound ) return false; | 154 | if ( mData->sound != a.mData->sound ) return false; |
155 | if ( mData->agent != a.mData->agent ) return false; | 155 | if ( mData->agent != a.mData->agent ) return false; |
156 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 156 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
157 | ( mData->url != a.mData->url ) ) return false; | 157 | ( mData->url != a.mData->url ) ) return false; |
158 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 158 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
159 | if ( mData->addresses != a.mData->addresses ) return false; | 159 | if ( mData->addresses != a.mData->addresses ) return false; |
160 | if ( mData->keys != a.mData->keys ) return false; | 160 | if ( mData->keys != a.mData->keys ) return false; |
161 | if ( mData->emails != a.mData->emails ) return false; | 161 | if ( mData->emails != a.mData->emails ) return false; |
162 | if ( mData->categories != a.mData->categories ) return false; | 162 | if ( mData->categories != a.mData->categories ) return false; |
163 | if ( mData->custom != a.mData->custom ) return false; | 163 | if ( mData->custom != a.mData->custom ) return false; |
164 | 164 | ||
165 | return true; | 165 | return true; |
166 | } | 166 | } |
167 | 167 | ||
168 | bool Addressee::operator!=( const Addressee &a ) const | 168 | bool Addressee::operator!=( const Addressee &a ) const |
169 | { | 169 | { |
170 | return !( a == *this ); | 170 | return !( a == *this ); |
171 | } | 171 | } |
172 | 172 | ||
173 | bool Addressee::isEmpty() const | 173 | bool Addressee::isEmpty() const |
174 | { | 174 | { |
175 | return mData->empty; | 175 | return mData->empty; |
176 | } | 176 | } |
177 | ulong Addressee::getCsum4List( const QStringList & attList) | ||
178 | { | ||
179 | int max = attList.count(); | ||
180 | ulong cSum = 0; | ||
181 | int j,k,i; | ||
182 | int add; | ||
183 | for ( i = 0; i < max ; ++i ) { | ||
184 | QString s = attList[i]; | ||
185 | if ( ! s.isEmpty() ){ | ||
186 | j = s.length(); | ||
187 | for ( k = 0; k < j; ++k ) { | ||
188 | int mul = k +1; | ||
189 | add = s[k].unicode (); | ||
190 | if ( k < 16 ) | ||
191 | mul = mul * mul; | ||
192 | int ii = i+1; | ||
193 | add = add * mul *ii*ii*ii; | ||
194 | cSum += add; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | } | ||
199 | //QString dump = attList.join(","); | ||
200 | //qDebug("csum: %d %s", cSum,dump.latin1()); | ||
201 | |||
202 | return cSum; | ||
203 | |||
204 | } | ||
205 | void Addressee::computeCsum(const QString &dev) | ||
206 | { | ||
207 | QStringList l; | ||
208 | if ( !mData->name.isEmpty() ) l.append(mData->name); | ||
209 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | ||
210 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | ||
211 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | ||
212 | if ( !mData->additionalName ) l.append( mData->additionalName ); | ||
213 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | ||
214 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | ||
215 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | ||
216 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | ||
217 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | ||
218 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | ||
219 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | ||
220 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | ||
221 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | ||
222 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | ||
223 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | ||
224 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | ||
225 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | ||
226 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | ||
227 | // if ( !mData->logo.isEmpty() ) l.append( ); | ||
228 | //if ( !mData->photo.isEmpty() ) l.append( ); | ||
229 | //if ( !mData->sound.isEmpty() ) l.append( ); | ||
230 | //if ( !mData->agent.isEmpty() ) l.append( ); | ||
231 | //if ( mData->url.isValid() ) l.append( ); | ||
232 | #if 0 | ||
233 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | ||
234 | if ( !mData->addresses.isEmpty() ) l.append( ); | ||
235 | //if ( !mData->keys.isEmpty() ) l.append( ); | ||
236 | if ( !mData->emails.isEmpty() ) l.append( ); | ||
237 | if ( !mData->categories .isEmpty() ) l.append( ); | ||
238 | if ( !mData->custom.isEmpty() ) l.append( ); | ||
239 | #endif | ||
240 | KABC::PhoneNumber::List phoneNumbers; | ||
241 | KABC::PhoneNumber::List::Iterator phoneIter; | ||
242 | |||
243 | QStringList t; | ||
244 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
245 | ++phoneIter ) | ||
246 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | ||
247 | t.sort(); | ||
248 | uint iii; | ||
249 | for ( iii = 0; iii < t.count(); ++iii) | ||
250 | l.append( t[iii] ); | ||
251 | t = mData->emails; | ||
252 | t.sort(); | ||
253 | for ( iii = 0; iii < t.count(); ++iii) | ||
254 | l.append( t[iii] ); | ||
255 | t = mData->categories; | ||
256 | t.sort(); | ||
257 | for ( iii = 0; iii < t.count(); ++iii) | ||
258 | l.append( t[iii] ); | ||
259 | t = mData->custom; | ||
260 | t.sort(); | ||
261 | for ( iii = 0; iii < t.count(); ++iii) | ||
262 | l.append( t[iii] ); | ||
263 | KABC::Address::List::Iterator addressIter; | ||
264 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | ||
265 | ++addressIter ) { | ||
266 | t = (*addressIter).asList(); | ||
267 | t.sort(); | ||
268 | for ( iii = 0; iii < t.count(); ++iii) | ||
269 | l.append( t[iii] ); | ||
270 | } | ||
271 | setCsum( dev, QString::number (getCsum4List(l)) ); | ||
272 | } | ||
177 | void Addressee::removeID(const QString &prof) | 273 | void Addressee::removeID(const QString &prof) |
178 | { | 274 | { |
179 | detach(); | 275 | detach(); |
180 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 276 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
181 | 277 | ||
182 | } | 278 | } |
183 | void Addressee::setID( const QString & prof , const QString & id ) | 279 | void Addressee::setID( const QString & prof , const QString & id ) |
184 | { | 280 | { |
185 | detach(); | 281 | detach(); |
186 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 282 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
187 | } | 283 | } |
188 | void Addressee::setTempSyncStat( int id ) | 284 | void Addressee::setTempSyncStat( int id ) |
189 | { | 285 | { |
190 | mTempSyncStat = id; | 286 | mTempSyncStat = id; |
191 | } | 287 | } |
192 | int Addressee::tempSyncStat() const | 288 | int Addressee::tempSyncStat() const |
193 | { | 289 | { |
194 | return mTempSyncStat; | 290 | return mTempSyncStat; |
195 | } | 291 | } |
196 | 292 | ||
197 | QString Addressee::getID( const QString & prof) | 293 | QString Addressee::getID( const QString & prof) |
198 | { | 294 | { |
199 | return KIdManager::getId ( mData->mExternalId, prof ); | 295 | return KIdManager::getId ( mData->mExternalId, prof ); |
200 | } | 296 | } |
201 | 297 | ||
202 | void Addressee::setCsum( const QString & prof , const QString & id ) | 298 | void Addressee::setCsum( const QString & prof , const QString & id ) |
203 | { | 299 | { |
204 | detach(); | 300 | detach(); |
205 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 301 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
206 | } | 302 | } |
207 | 303 | ||
208 | QString Addressee::getCsum( const QString & prof) | 304 | QString Addressee::getCsum( const QString & prof) |
@@ -1421,69 +1517,68 @@ void Addressee::removeCategory( const QString &c ) | |||
1421 | 1517 | ||
1422 | bool Addressee::hasCategory( const QString &c ) const | 1518 | bool Addressee::hasCategory( const QString &c ) const |
1423 | { | 1519 | { |
1424 | return ( mData->categories.contains( c ) ); | 1520 | return ( mData->categories.contains( c ) ); |
1425 | } | 1521 | } |
1426 | 1522 | ||
1427 | void Addressee::setCategories( const QStringList &c ) | 1523 | void Addressee::setCategories( const QStringList &c ) |
1428 | { | 1524 | { |
1429 | detach(); | 1525 | detach(); |
1430 | mData->empty = false; | 1526 | mData->empty = false; |
1431 | 1527 | ||
1432 | mData->categories = c; | 1528 | mData->categories = c; |
1433 | } | 1529 | } |
1434 | 1530 | ||
1435 | QStringList Addressee::categories() const | 1531 | QStringList Addressee::categories() const |
1436 | { | 1532 | { |
1437 | return mData->categories; | 1533 | return mData->categories; |
1438 | } | 1534 | } |
1439 | 1535 | ||
1440 | void Addressee::insertCustom( const QString &app, const QString &name, | 1536 | void Addressee::insertCustom( const QString &app, const QString &name, |
1441 | const QString &value ) | 1537 | const QString &value ) |
1442 | { | 1538 | { |
1443 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1539 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1444 | 1540 | ||
1445 | detach(); | 1541 | detach(); |
1446 | mData->empty = false; | 1542 | mData->empty = false; |
1447 | 1543 | ||
1448 | QString qualifiedName = app + "-" + name + ":"; | 1544 | QString qualifiedName = app + "-" + name + ":"; |
1449 | 1545 | ||
1450 | QStringList::Iterator it; | 1546 | QStringList::Iterator it; |
1451 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1547 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1452 | if ( (*it).startsWith( qualifiedName ) ) { | 1548 | if ( (*it).startsWith( qualifiedName ) ) { |
1453 | (*it) = qualifiedName + value; | 1549 | (*it) = qualifiedName + value; |
1454 | return; | 1550 | return; |
1455 | } | 1551 | } |
1456 | } | 1552 | } |
1457 | |||
1458 | mData->custom.append( qualifiedName + value ); | 1553 | mData->custom.append( qualifiedName + value ); |
1459 | } | 1554 | } |
1460 | 1555 | ||
1461 | void Addressee::removeCustom( const QString &app, const QString &name) | 1556 | void Addressee::removeCustom( const QString &app, const QString &name) |
1462 | { | 1557 | { |
1463 | detach(); | 1558 | detach(); |
1464 | 1559 | ||
1465 | QString qualifiedName = app + "-" + name + ":"; | 1560 | QString qualifiedName = app + "-" + name + ":"; |
1466 | 1561 | ||
1467 | QStringList::Iterator it; | 1562 | QStringList::Iterator it; |
1468 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1563 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1469 | if ( (*it).startsWith( qualifiedName ) ) { | 1564 | if ( (*it).startsWith( qualifiedName ) ) { |
1470 | mData->custom.remove( it ); | 1565 | mData->custom.remove( it ); |
1471 | return; | 1566 | return; |
1472 | } | 1567 | } |
1473 | } | 1568 | } |
1474 | } | 1569 | } |
1475 | 1570 | ||
1476 | QString Addressee::custom( const QString &app, const QString &name ) const | 1571 | QString Addressee::custom( const QString &app, const QString &name ) const |
1477 | { | 1572 | { |
1478 | QString qualifiedName = app + "-" + name + ":"; | 1573 | QString qualifiedName = app + "-" + name + ":"; |
1479 | QString value; | 1574 | QString value; |
1480 | 1575 | ||
1481 | QStringList::ConstIterator it; | 1576 | QStringList::ConstIterator it; |
1482 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1577 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1483 | if ( (*it).startsWith( qualifiedName ) ) { | 1578 | if ( (*it).startsWith( qualifiedName ) ) { |
1484 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1579 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1485 | break; | 1580 | break; |
1486 | } | 1581 | } |
1487 | } | 1582 | } |
1488 | 1583 | ||
1489 | return value; | 1584 | return value; |
diff --git a/kabc/addressee.h b/kabc/addressee.h index f098371..0805458 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -77,64 +77,66 @@ class Resource; | |||
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 | */ |
80 | class Addressee | 80 | class 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 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | ||
110 | ulong getCsum4List( const QStringList & attList); | ||
109 | /** | 111 | /** |
110 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
111 | */ | 113 | */ |
112 | bool isEmpty() const; | 114 | bool isEmpty() const; |
113 | 115 | ||
114 | /** | 116 | /** |
115 | Set unique identifier. | 117 | Set unique identifier. |
116 | */ | 118 | */ |
117 | void setUid( const QString &uid ); | 119 | void setUid( const QString &uid ); |
118 | /** | 120 | /** |
119 | Return unique identifier. | 121 | Return unique identifier. |
120 | */ | 122 | */ |
121 | QString uid() const; | 123 | QString uid() const; |
122 | /** | 124 | /** |
123 | Return translated label for uid field. | 125 | Return translated label for uid field. |
124 | */ | 126 | */ |
125 | static QString uidLabel(); | 127 | static QString uidLabel(); |
126 | 128 | ||
127 | /** | 129 | /** |
128 | Set name. | 130 | Set name. |
129 | */ | 131 | */ |
130 | void setName( const QString &name ); | 132 | void setName( const QString &name ); |
131 | /** | 133 | /** |
132 | Return name. | 134 | Return name. |
133 | */ | 135 | */ |
134 | QString name() const; | 136 | QString name() const; |
135 | /** | 137 | /** |
136 | Return translated label for name field. | 138 | Return translated label for name field. |
137 | */ | 139 | */ |
138 | static QString nameLabel(); | 140 | static QString nameLabel(); |
139 | 141 | ||
140 | /** | 142 | /** |