author | zautrix <zautrix> | 2004-10-09 02:17:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 02:17:06 (UTC) |
commit | c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (patch) (unidiff) | |
tree | b83f7cfe5d4bb681b756fe95446e5e3fc193bc36 /kabc | |
parent | 07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (diff) | |
download | kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.zip kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.gz kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.bz2 |
import ir fixes
-rw-r--r-- | kabc/addressbook.cpp | 16 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 17 | ||||
-rw-r--r-- | kabc/addressee.h | 1 |
4 files changed, 31 insertions, 5 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index dc3cda1..bf6d053 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -213,400 +213,408 @@ 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 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 217 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
218 | { | 218 | { |
219 | return ( d->mIt != it.d->mIt ); | 219 | return ( d->mIt != it.d->mIt ); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | AddressBook::AddressBook() | 223 | AddressBook::AddressBook() |
224 | { | 224 | { |
225 | init(0, "contact"); | 225 | init(0, "contact"); |
226 | } | 226 | } |
227 | 227 | ||
228 | AddressBook::AddressBook( const QString &config ) | 228 | AddressBook::AddressBook( const QString &config ) |
229 | { | 229 | { |
230 | init(config, "contact"); | 230 | init(config, "contact"); |
231 | } | 231 | } |
232 | 232 | ||
233 | AddressBook::AddressBook( const QString &config, const QString &family ) | 233 | AddressBook::AddressBook( const QString &config, const QString &family ) |
234 | { | 234 | { |
235 | init(config, family); | 235 | init(config, family); |
236 | 236 | ||
237 | } | 237 | } |
238 | 238 | ||
239 | // the default family is "contact" | 239 | // the default family is "contact" |
240 | void AddressBook::init(const QString &config, const QString &family ) | 240 | void AddressBook::init(const QString &config, const QString &family ) |
241 | { | 241 | { |
242 | blockLSEchange = false; | 242 | blockLSEchange = false; |
243 | d = new AddressBookData; | 243 | d = new AddressBookData; |
244 | QString fami = family; | 244 | QString fami = family; |
245 | if (config != 0) { | 245 | if (config != 0) { |
246 | if ( family == "syncContact" ) { | 246 | if ( family == "syncContact" ) { |
247 | qDebug("creating sync config "); | 247 | qDebug("creating sync config "); |
248 | fami = "contact"; | 248 | fami = "contact"; |
249 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 249 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
250 | con->setGroup( "General" ); | 250 | con->setGroup( "General" ); |
251 | con->writeEntry( "ResourceKeys", QString("sync") ); | 251 | con->writeEntry( "ResourceKeys", QString("sync") ); |
252 | con->writeEntry( "Standard", QString("sync") ); | 252 | con->writeEntry( "Standard", QString("sync") ); |
253 | con->setGroup( "Resource_sync" ); | 253 | con->setGroup( "Resource_sync" ); |
254 | con->writeEntry( "FileName", config ); | 254 | con->writeEntry( "FileName", config ); |
255 | con->writeEntry( "FileFormat", QString("vcard") ); | 255 | con->writeEntry( "FileFormat", QString("vcard") ); |
256 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 256 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
257 | con->writeEntry( "ResourceName", QString("sync_res") ); | 257 | con->writeEntry( "ResourceName", QString("sync_res") ); |
258 | if ( config.right(4) == ".xml" ) | 258 | if ( config.right(4) == ".xml" ) |
259 | con->writeEntry( "ResourceType", QString("qtopia") ); | 259 | con->writeEntry( "ResourceType", QString("qtopia") ); |
260 | else if ( config == "sharp" ) { | 260 | else if ( config == "sharp" ) { |
261 | con->writeEntry( "ResourceType", QString("sharp") ); | 261 | con->writeEntry( "ResourceType", QString("sharp") ); |
262 | } else { | 262 | } else { |
263 | con->writeEntry( "ResourceType", QString("file") ); | 263 | con->writeEntry( "ResourceType", QString("file") ); |
264 | } | 264 | } |
265 | //con->sync(); | 265 | //con->sync(); |
266 | d->mConfig = con; | 266 | d->mConfig = con; |
267 | } | 267 | } |
268 | else | 268 | else |
269 | d->mConfig = new KConfig( locateLocal("config", config) ); | 269 | d->mConfig = new KConfig( locateLocal("config", config) ); |
270 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 270 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
271 | } | 271 | } |
272 | else { | 272 | else { |
273 | d->mConfig = 0; | 273 | d->mConfig = 0; |
274 | // qDebug("AddressBook::init 1 config=0"); | 274 | // qDebug("AddressBook::init 1 config=0"); |
275 | } | 275 | } |
276 | 276 | ||
277 | //US d->mErrorHandler = 0; | 277 | //US d->mErrorHandler = 0; |
278 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 278 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
279 | d->mManager->readConfig( d->mConfig ); | 279 | d->mManager->readConfig( d->mConfig ); |
280 | if ( family == "syncContact" ) { | 280 | if ( family == "syncContact" ) { |
281 | KRES::Manager<Resource> *manager = d->mManager; | 281 | KRES::Manager<Resource> *manager = d->mManager; |
282 | KRES::Manager<Resource>::ActiveIterator it; | 282 | KRES::Manager<Resource>::ActiveIterator it; |
283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
284 | (*it)->setAddressBook( this ); | 284 | (*it)->setAddressBook( this ); |
285 | if ( !(*it)->open() ) | 285 | if ( !(*it)->open() ) |
286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
287 | } | 287 | } |
288 | Resource *res = standardResource(); | 288 | Resource *res = standardResource(); |
289 | if ( !res ) { | 289 | if ( !res ) { |
290 | qDebug("ERROR: no standard resource"); | 290 | qDebug("ERROR: no standard resource"); |
291 | res = manager->createResource( "file" ); | 291 | res = manager->createResource( "file" ); |
292 | if ( res ) | 292 | if ( res ) |
293 | { | 293 | { |
294 | addResource( res ); | 294 | addResource( res ); |
295 | } | 295 | } |
296 | else | 296 | else |
297 | qDebug(" No resource available!!!"); | 297 | qDebug(" No resource available!!!"); |
298 | } | 298 | } |
299 | setStandardResource( res ); | 299 | setStandardResource( res ); |
300 | manager->writeConfig(); | 300 | manager->writeConfig(); |
301 | } | 301 | } |
302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
303 | "X-Department", "KADDRESSBOOK" ); | 303 | "X-Department", "KADDRESSBOOK" ); |
304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
305 | "X-Profession", "KADDRESSBOOK" ); | 305 | "X-Profession", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
307 | "X-AssistantsName", "KADDRESSBOOK" ); | 307 | "X-AssistantsName", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
309 | "X-ManagersName", "KADDRESSBOOK" ); | 309 | "X-ManagersName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
311 | "X-SpousesName", "KADDRESSBOOK" ); | 311 | "X-SpousesName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
313 | "X-Office", "KADDRESSBOOK" ); | 313 | "X-Office", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
315 | "X-IMAddress", "KADDRESSBOOK" ); | 315 | "X-IMAddress", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
317 | "X-Anniversary", "KADDRESSBOOK" ); | 317 | "X-Anniversary", "KADDRESSBOOK" ); |
318 | 318 | ||
319 | //US added this field to become compatible with Opie/qtopia addressbook | 319 | //US added this field to become compatible with Opie/qtopia addressbook |
320 | // values can be "female" or "male" or "". An empty field represents undefined. | 320 | // values can be "female" or "male" or "". An empty field represents undefined. |
321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
322 | "X-Gender", "KADDRESSBOOK" ); | 322 | "X-Gender", "KADDRESSBOOK" ); |
323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
324 | "X-Children", "KADDRESSBOOK" ); | 324 | "X-Children", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
328 | "X-ExternalID", "KADDRESSBOOK" ); | 328 | "X-ExternalID", "KADDRESSBOOK" ); |
329 | } | 329 | } |
330 | 330 | ||
331 | AddressBook::~AddressBook() | 331 | AddressBook::~AddressBook() |
332 | { | 332 | { |
333 | delete d->mConfig; d->mConfig = 0; | 333 | delete d->mConfig; d->mConfig = 0; |
334 | delete d->mManager; d->mManager = 0; | 334 | delete d->mManager; d->mManager = 0; |
335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
336 | delete d; d = 0; | 336 | delete d; d = 0; |
337 | } | 337 | } |
338 | 338 | ||
339 | bool AddressBook::load() | 339 | bool AddressBook::load() |
340 | { | 340 | { |
341 | 341 | ||
342 | 342 | ||
343 | clear(); | 343 | clear(); |
344 | 344 | ||
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } | 351 | } |
352 | 352 | ||
353 | // mark all addressees as unchanged | 353 | // mark all addressees as unchanged |
354 | Addressee::List::Iterator addrIt; | 354 | Addressee::List::Iterator addrIt; |
355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
356 | (*addrIt).setChanged( false ); | 356 | (*addrIt).setChanged( false ); |
357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
358 | if ( !id.isEmpty() ) { | 358 | if ( !id.isEmpty() ) { |
359 | //qDebug("setId aa %s ", id.latin1()); | 359 | //qDebug("setId aa %s ", id.latin1()); |
360 | (*addrIt).setIDStr(id ); | 360 | (*addrIt).setIDStr(id ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | blockLSEchange = true; | 363 | blockLSEchange = true; |
364 | return ok; | 364 | return ok; |
365 | } | 365 | } |
366 | 366 | ||
367 | bool AddressBook::save( Ticket *ticket ) | 367 | bool AddressBook::save( Ticket *ticket ) |
368 | { | 368 | { |
369 | kdDebug(5700) << "AddressBook::save()"<< endl; | 369 | kdDebug(5700) << "AddressBook::save()"<< endl; |
370 | 370 | ||
371 | if ( ticket->resource() ) { | 371 | if ( ticket->resource() ) { |
372 | deleteRemovedAddressees(); | 372 | deleteRemovedAddressees(); |
373 | return ticket->resource()->save( ticket ); | 373 | return ticket->resource()->save( ticket ); |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | void AddressBook::export2File( QString fileName ) | 378 | void AddressBook::export2File( QString fileName ) |
379 | { | 379 | { |
380 | 380 | ||
381 | QFile outFile( fileName ); | 381 | QFile outFile( fileName ); |
382 | if ( !outFile.open( IO_WriteOnly ) ) { | 382 | if ( !outFile.open( IO_WriteOnly ) ) { |
383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
384 | KMessageBox::error( 0, text.arg( fileName ) ); | 384 | KMessageBox::error( 0, text.arg( fileName ) ); |
385 | return ; | 385 | return ; |
386 | } | 386 | } |
387 | QTextStream t( &outFile ); | 387 | QTextStream t( &outFile ); |
388 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 388 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
389 | Iterator it; | 389 | Iterator it; |
390 | KABC::VCardConverter::Version version; | 390 | KABC::VCardConverter::Version version; |
391 | version = KABC::VCardConverter::v3_0; | 391 | version = KABC::VCardConverter::v3_0; |
392 | for ( it = begin(); it != end(); ++it ) { | 392 | for ( it = begin(); it != end(); ++it ) { |
393 | if ( !(*it).IDStr().isEmpty() ) { | 393 | if ( !(*it).IDStr().isEmpty() ) { |
394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
395 | } | 395 | } |
396 | KABC::VCardConverter converter; | 396 | KABC::VCardConverter converter; |
397 | QString vcard; | 397 | QString vcard; |
398 | //Resource *resource() const; | 398 | //Resource *resource() const; |
399 | converter.addresseeToVCard( *it, vcard, version ); | 399 | converter.addresseeToVCard( *it, vcard, version ); |
400 | t << vcard << "\r\n"; | 400 | t << vcard << "\r\n"; |
401 | } | 401 | } |
402 | t << "\r\n\r\n"; | 402 | t << "\r\n\r\n"; |
403 | outFile.close(); | 403 | outFile.close(); |
404 | } | 404 | } |
405 | void AddressBook::importFromFile( QString fileName ) | 405 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) |
406 | { | 406 | { |
407 | 407 | ||
408 | KABC::Addressee::List list; | 408 | KABC::Addressee::List list; |
409 | QFile file( fileName ); | 409 | QFile file( fileName ); |
410 | 410 | ||
411 | file.open( IO_ReadOnly ); | 411 | file.open( IO_ReadOnly ); |
412 | QByteArray rawData = file.readAll(); | 412 | QByteArray rawData = file.readAll(); |
413 | file.close(); | 413 | file.close(); |
414 | 414 | qDebug("AddressBook::importFromFile "); | |
415 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 415 | QString data; |
416 | if ( replaceLabel ) { | ||
417 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | ||
418 | data.replace ( QRegExp("LABEL") , "ADR" ); | ||
419 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | ||
420 | } else | ||
421 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | ||
416 | KABC::VCardTool tool; | 422 | KABC::VCardTool tool; |
417 | list = tool.parseVCards( data ); | 423 | list = tool.parseVCards( data ); |
418 | KABC::Addressee::List::Iterator it; | 424 | KABC::Addressee::List::Iterator it; |
419 | for ( it = list.begin(); it != list.end(); ++it ) { | 425 | for ( it = list.begin(); it != list.end(); ++it ) { |
420 | (*it).setResource( 0 ); | 426 | (*it).setResource( 0 ); |
427 | if ( replaceLabel ) | ||
428 | (*it).removeVoice(); | ||
421 | insertAddressee( (*it), false, true ); | 429 | insertAddressee( (*it), false, true ); |
422 | } | 430 | } |
423 | 431 | ||
424 | } | 432 | } |
425 | 433 | ||
426 | bool AddressBook::saveAB() | 434 | bool AddressBook::saveAB() |
427 | { | 435 | { |
428 | bool ok = true; | 436 | bool ok = true; |
429 | 437 | ||
430 | deleteRemovedAddressees(); | 438 | deleteRemovedAddressees(); |
431 | Iterator ait; | 439 | Iterator ait; |
432 | for ( ait = begin(); ait != end(); ++ait ) { | 440 | for ( ait = begin(); ait != end(); ++ait ) { |
433 | if ( !(*ait).IDStr().isEmpty() ) { | 441 | if ( !(*ait).IDStr().isEmpty() ) { |
434 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 442 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
435 | } | 443 | } |
436 | } | 444 | } |
437 | KRES::Manager<Resource>::ActiveIterator it; | 445 | KRES::Manager<Resource>::ActiveIterator it; |
438 | KRES::Manager<Resource> *manager = d->mManager; | 446 | KRES::Manager<Resource> *manager = d->mManager; |
439 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 447 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
440 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 448 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
441 | Ticket *ticket = requestSaveTicket( *it ); | 449 | Ticket *ticket = requestSaveTicket( *it ); |
442 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 450 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
443 | if ( !ticket ) { | 451 | if ( !ticket ) { |
444 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 452 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
445 | .arg( (*it)->resourceName() ) ); | 453 | .arg( (*it)->resourceName() ) ); |
446 | return false; | 454 | return false; |
447 | } | 455 | } |
448 | 456 | ||
449 | //if ( !save( ticket ) ) | 457 | //if ( !save( ticket ) ) |
450 | if ( ticket->resource() ) { | 458 | if ( ticket->resource() ) { |
451 | if ( ! ticket->resource()->save( ticket ) ) | 459 | if ( ! ticket->resource()->save( ticket ) ) |
452 | ok = false; | 460 | ok = false; |
453 | } else | 461 | } else |
454 | ok = false; | 462 | ok = false; |
455 | 463 | ||
456 | } | 464 | } |
457 | } | 465 | } |
458 | return ok; | 466 | return ok; |
459 | } | 467 | } |
460 | 468 | ||
461 | AddressBook::Iterator AddressBook::begin() | 469 | AddressBook::Iterator AddressBook::begin() |
462 | { | 470 | { |
463 | Iterator it = Iterator(); | 471 | Iterator it = Iterator(); |
464 | it.d->mIt = d->mAddressees.begin(); | 472 | it.d->mIt = d->mAddressees.begin(); |
465 | return it; | 473 | return it; |
466 | } | 474 | } |
467 | 475 | ||
468 | AddressBook::ConstIterator AddressBook::begin() const | 476 | AddressBook::ConstIterator AddressBook::begin() const |
469 | { | 477 | { |
470 | ConstIterator it = ConstIterator(); | 478 | ConstIterator it = ConstIterator(); |
471 | it.d->mIt = d->mAddressees.begin(); | 479 | it.d->mIt = d->mAddressees.begin(); |
472 | return it; | 480 | return it; |
473 | } | 481 | } |
474 | 482 | ||
475 | AddressBook::Iterator AddressBook::end() | 483 | AddressBook::Iterator AddressBook::end() |
476 | { | 484 | { |
477 | Iterator it = Iterator(); | 485 | Iterator it = Iterator(); |
478 | it.d->mIt = d->mAddressees.end(); | 486 | it.d->mIt = d->mAddressees.end(); |
479 | return it; | 487 | return it; |
480 | } | 488 | } |
481 | 489 | ||
482 | AddressBook::ConstIterator AddressBook::end() const | 490 | AddressBook::ConstIterator AddressBook::end() const |
483 | { | 491 | { |
484 | ConstIterator it = ConstIterator(); | 492 | ConstIterator it = ConstIterator(); |
485 | it.d->mIt = d->mAddressees.end(); | 493 | it.d->mIt = d->mAddressees.end(); |
486 | return it; | 494 | return it; |
487 | } | 495 | } |
488 | 496 | ||
489 | void AddressBook::clear() | 497 | void AddressBook::clear() |
490 | { | 498 | { |
491 | d->mAddressees.clear(); | 499 | d->mAddressees.clear(); |
492 | } | 500 | } |
493 | 501 | ||
494 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 502 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
495 | { | 503 | { |
496 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 504 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
497 | 505 | ||
498 | if ( !resource ) | 506 | if ( !resource ) |
499 | { | 507 | { |
500 | qDebug("AddressBook::requestSaveTicket no resource" ); | 508 | qDebug("AddressBook::requestSaveTicket no resource" ); |
501 | resource = standardResource(); | 509 | resource = standardResource(); |
502 | } | 510 | } |
503 | 511 | ||
504 | KRES::Manager<Resource>::ActiveIterator it; | 512 | KRES::Manager<Resource>::ActiveIterator it; |
505 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 513 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
506 | if ( (*it) == resource ) { | 514 | if ( (*it) == resource ) { |
507 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 515 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
508 | return 0; | 516 | return 0; |
509 | else | 517 | else |
510 | return (*it)->requestSaveTicket(); | 518 | return (*it)->requestSaveTicket(); |
511 | } | 519 | } |
512 | } | 520 | } |
513 | 521 | ||
514 | return 0; | 522 | return 0; |
515 | } | 523 | } |
516 | 524 | ||
517 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 525 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
518 | { | 526 | { |
519 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 527 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
520 | //qDebug("block insert "); | 528 | //qDebug("block insert "); |
521 | return; | 529 | return; |
522 | } | 530 | } |
523 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 531 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
524 | bool found = false; | 532 | bool found = false; |
525 | Addressee::List::Iterator it; | 533 | Addressee::List::Iterator it; |
526 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 534 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
527 | if ( a.uid() == (*it).uid() ) { | 535 | if ( a.uid() == (*it).uid() ) { |
528 | 536 | ||
529 | bool changed = false; | 537 | bool changed = false; |
530 | Addressee addr = a; | 538 | Addressee addr = a; |
531 | if ( addr != (*it) ) | 539 | if ( addr != (*it) ) |
532 | changed = true; | 540 | changed = true; |
533 | 541 | ||
534 | if ( takeResource ) { | 542 | if ( takeResource ) { |
535 | Resource * res = (*it).resource(); | 543 | Resource * res = (*it).resource(); |
536 | (*it) = a; | 544 | (*it) = a; |
537 | (*it).setResource( res ); | 545 | (*it).setResource( res ); |
538 | } else { | 546 | } else { |
539 | (*it) = a; | 547 | (*it) = a; |
540 | if ( (*it).resource() == 0 ) | 548 | if ( (*it).resource() == 0 ) |
541 | (*it).setResource( standardResource() ); | 549 | (*it).setResource( standardResource() ); |
542 | } | 550 | } |
543 | if ( changed ) { | 551 | if ( changed ) { |
544 | if ( setRev ) { | 552 | if ( setRev ) { |
545 | 553 | ||
546 | // get rid of micro seconds | 554 | // get rid of micro seconds |
547 | QDateTime dt = QDateTime::currentDateTime(); | 555 | QDateTime dt = QDateTime::currentDateTime(); |
548 | QTime t = dt.time(); | 556 | QTime t = dt.time(); |
549 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 557 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
550 | (*it).setRevision( dt ); | 558 | (*it).setRevision( dt ); |
551 | } | 559 | } |
552 | (*it).setChanged( true ); | 560 | (*it).setChanged( true ); |
553 | } | 561 | } |
554 | 562 | ||
555 | found = true; | 563 | found = true; |
556 | } else { | 564 | } else { |
557 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 565 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
558 | QString name = (*it).uid().mid( 19 ); | 566 | QString name = (*it).uid().mid( 19 ); |
559 | Addressee b = a; | 567 | Addressee b = a; |
560 | QString id = b.getID( name ); | 568 | QString id = b.getID( name ); |
561 | if ( ! id.isEmpty() ) { | 569 | if ( ! id.isEmpty() ) { |
562 | QString des = (*it).note(); | 570 | QString des = (*it).note(); |
563 | int startN; | 571 | int startN; |
564 | if( (startN = des.find( id ) ) >= 0 ) { | 572 | if( (startN = des.find( id ) ) >= 0 ) { |
565 | int endN = des.find( ",", startN+1 ); | 573 | int endN = des.find( ",", startN+1 ); |
566 | des = des.left( startN ) + des.mid( endN+1 ); | 574 | des = des.left( startN ) + des.mid( endN+1 ); |
567 | (*it).setNote( des ); | 575 | (*it).setNote( des ); |
568 | } | 576 | } |
569 | } | 577 | } |
570 | } | 578 | } |
571 | } | 579 | } |
572 | } | 580 | } |
573 | if ( found ) | 581 | if ( found ) |
574 | return; | 582 | return; |
575 | d->mAddressees.append( a ); | 583 | d->mAddressees.append( a ); |
576 | Addressee& addr = d->mAddressees.last(); | 584 | Addressee& addr = d->mAddressees.last(); |
577 | if ( addr.resource() == 0 ) | 585 | if ( addr.resource() == 0 ) |
578 | addr.setResource( standardResource() ); | 586 | addr.setResource( standardResource() ); |
579 | 587 | ||
580 | addr.setChanged( true ); | 588 | addr.setChanged( true ); |
581 | } | 589 | } |
582 | 590 | ||
583 | void AddressBook::removeAddressee( const Addressee &a ) | 591 | void AddressBook::removeAddressee( const Addressee &a ) |
584 | { | 592 | { |
585 | Iterator it; | 593 | Iterator it; |
586 | Iterator it2; | 594 | Iterator it2; |
587 | bool found = false; | 595 | bool found = false; |
588 | for ( it = begin(); it != end(); ++it ) { | 596 | for ( it = begin(); it != end(); ++it ) { |
589 | if ( a.uid() == (*it).uid() ) { | 597 | if ( a.uid() == (*it).uid() ) { |
590 | found = true; | 598 | found = true; |
591 | it2 = it; | 599 | it2 = it; |
592 | } else { | 600 | } else { |
593 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 601 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
594 | QString name = (*it).uid().mid( 19 ); | 602 | QString name = (*it).uid().mid( 19 ); |
595 | Addressee b = a; | 603 | Addressee b = a; |
596 | QString id = b.getID( name ); | 604 | QString id = b.getID( name ); |
597 | if ( ! id.isEmpty() ) { | 605 | if ( ! id.isEmpty() ) { |
598 | QString des = (*it).note(); | 606 | QString des = (*it).note(); |
599 | if( des.find( id ) < 0 ) { | 607 | if( des.find( id ) < 0 ) { |
600 | des += id + ","; | 608 | des += id + ","; |
601 | (*it).setNote( des ); | 609 | (*it).setNote( des ); |
602 | } | 610 | } |
603 | } | 611 | } |
604 | } | 612 | } |
605 | 613 | ||
606 | } | 614 | } |
607 | } | 615 | } |
608 | 616 | ||
609 | if ( found ) | 617 | if ( found ) |
610 | removeAddressee( it2 ); | 618 | removeAddressee( it2 ); |
611 | 619 | ||
612 | } | 620 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 3603ec1..cea1b03 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,338 +1,338 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
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 | void export2File( QString fileName ); | 145 | void export2File( QString fileName ); |
146 | void importFromFile( QString fileName ); | 146 | void importFromFile( QString fileName, bool replaceLabel = false ); |
147 | /** | 147 | /** |
148 | Returns a iterator for first entry of address book. | 148 | Returns a iterator for first entry of address book. |
149 | */ | 149 | */ |
150 | Iterator begin(); | 150 | Iterator begin(); |
151 | 151 | ||
152 | /** | 152 | /** |
153 | Returns a const iterator for first entry of address book. | 153 | Returns a const iterator for first entry of address book. |
154 | */ | 154 | */ |
155 | ConstIterator begin() const; | 155 | ConstIterator begin() const; |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Returns a iterator for first entry of address book. | 158 | Returns a iterator for first entry of address book. |
159 | */ | 159 | */ |
160 | Iterator end(); | 160 | Iterator end(); |
161 | 161 | ||
162 | /** | 162 | /** |
163 | Returns a const iterator for first entry of address book. | 163 | Returns a const iterator for first entry of address book. |
164 | */ | 164 | */ |
165 | ConstIterator end() const; | 165 | ConstIterator end() const; |
166 | 166 | ||
167 | /** | 167 | /** |
168 | Removes all entries from address book. | 168 | Removes all entries from address book. |
169 | */ | 169 | */ |
170 | void clear(); | 170 | void clear(); |
171 | 171 | ||
172 | /** | 172 | /** |
173 | Insert an Addressee object into address book. If an object with the same | 173 | Insert an Addressee object into address book. If an object with the same |
174 | unique id already exists in the address book it it replaced by the new | 174 | unique id already exists in the address book it it replaced by the new |
175 | one. If not the new object is appended to the address book. | 175 | one. If not the new object is appended to the address book. |
176 | */ | 176 | */ |
177 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 177 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
178 | 178 | ||
179 | /** | 179 | /** |
180 | Removes entry from the address book. | 180 | Removes entry from the address book. |
181 | */ | 181 | */ |
182 | void removeAddressee( const Addressee & ); | 182 | void removeAddressee( const Addressee & ); |
183 | 183 | ||
184 | /** | 184 | /** |
185 | This is like @ref removeAddressee() just above, with the difference that | 185 | This is like @ref removeAddressee() just above, with the difference that |
186 | the first element is a iterator, returned by @ref begin(). | 186 | the first element is a iterator, returned by @ref begin(). |
187 | */ | 187 | */ |
188 | void removeAddressee( const Iterator & ); | 188 | void removeAddressee( const Iterator & ); |
189 | 189 | ||
190 | /** | 190 | /** |
191 | Find the specified entry in address book. Returns end(), if the entry | 191 | Find the specified entry in address book. Returns end(), if the entry |
192 | couldn't be found. | 192 | couldn't be found. |
193 | */ | 193 | */ |
194 | Iterator find( const Addressee & ); | 194 | Iterator find( const Addressee & ); |
195 | 195 | ||
196 | /** | 196 | /** |
197 | Find the entry specified by an unique id. Returns an empty Addressee | 197 | Find the entry specified by an unique id. Returns an empty Addressee |
198 | object, if the address book does not contain an entry with this id. | 198 | object, if the address book does not contain an entry with this id. |
199 | */ | 199 | */ |
200 | Addressee findByUid( const QString & ); | 200 | Addressee findByUid( const QString & ); |
201 | 201 | ||
202 | 202 | ||
203 | /** | 203 | /** |
204 | Returns a list of all addressees in the address book. This list can | 204 | Returns a list of all addressees in the address book. This list can |
205 | be sorted with @ref KABC::AddresseeList for example. | 205 | be sorted with @ref KABC::AddresseeList for example. |
206 | */ | 206 | */ |
207 | Addressee::List allAddressees(); | 207 | Addressee::List allAddressees(); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | Find all entries with the specified name in the address book. Returns | 210 | Find all entries with the specified name in the address book. Returns |
211 | an empty list, if no entries could be found. | 211 | an empty list, if no entries could be found. |
212 | */ | 212 | */ |
213 | Addressee::List findByName( const QString & ); | 213 | Addressee::List findByName( const QString & ); |
214 | 214 | ||
215 | /** | 215 | /** |
216 | Find all entries with the specified email address in the address book. | 216 | Find all entries with the specified email address in the address book. |
217 | Returns an empty list, if no entries could be found. | 217 | Returns an empty list, if no entries could be found. |
218 | */ | 218 | */ |
219 | Addressee::List findByEmail( const QString & ); | 219 | Addressee::List findByEmail( const QString & ); |
220 | 220 | ||
221 | /** | 221 | /** |
222 | Find all entries wich have the specified category in the address book. | 222 | Find all entries wich have the specified category in the address book. |
223 | Returns an empty list, if no entries could be found. | 223 | Returns an empty list, if no entries could be found. |
224 | */ | 224 | */ |
225 | Addressee::List findByCategory( const QString & ); | 225 | Addressee::List findByCategory( const QString & ); |
226 | 226 | ||
227 | /** | 227 | /** |
228 | Return a string identifying this addressbook. | 228 | Return a string identifying this addressbook. |
229 | */ | 229 | */ |
230 | virtual QString identifier(); | 230 | virtual QString identifier(); |
231 | 231 | ||
232 | /** | 232 | /** |
233 | Used for debug output. | 233 | Used for debug output. |
234 | */ | 234 | */ |
235 | void dump() const; | 235 | void dump() const; |
236 | 236 | ||
237 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 237 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
238 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 238 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
239 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 239 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
240 | 240 | ||
241 | /** | 241 | /** |
242 | Return list of all Fields known to the address book which are associated | 242 | Return list of all Fields known to the address book which are associated |
243 | with the given field category. | 243 | with the given field category. |
244 | */ | 244 | */ |
245 | Field::List fields( int category = Field::All ); | 245 | Field::List fields( int category = Field::All ); |
246 | 246 | ||
247 | /** | 247 | /** |
248 | Add custom field to address book. | 248 | Add custom field to address book. |
249 | 249 | ||
250 | @param label User visible label of the field. | 250 | @param label User visible label of the field. |
251 | @param category Ored list of field categories. | 251 | @param category Ored list of field categories. |
252 | @param key Identifier used as key for reading and writing the field. | 252 | @param key Identifier used as key for reading and writing the field. |
253 | @param app String used as application key for reading and writing | 253 | @param app String used as application key for reading and writing |
254 | the field. | 254 | the field. |
255 | */ | 255 | */ |
256 | bool addCustomField( const QString &label, int category = Field::All, | 256 | bool addCustomField( const QString &label, int category = Field::All, |
257 | const QString &key = QString::null, | 257 | const QString &key = QString::null, |
258 | const QString &app = QString::null ); | 258 | const QString &app = QString::null ); |
259 | 259 | ||
260 | 260 | ||
261 | /** | 261 | /** |
262 | Add address book resource. | 262 | Add address book resource. |
263 | */ | 263 | */ |
264 | bool addResource( Resource * ); | 264 | bool addResource( Resource * ); |
265 | 265 | ||
266 | /** | 266 | /** |
267 | Remove address book resource. | 267 | Remove address book resource. |
268 | */ | 268 | */ |
269 | bool removeResource( Resource * ); | 269 | bool removeResource( Resource * ); |
270 | 270 | ||
271 | /** | 271 | /** |
272 | Return pointer list of all resources. | 272 | Return pointer list of all resources. |
273 | */ | 273 | */ |
274 | QPtrList<Resource> resources(); | 274 | QPtrList<Resource> resources(); |
275 | 275 | ||
276 | /** | 276 | /** |
277 | Set the @p ErrorHandler, that is used by @ref error() to | 277 | Set the @p ErrorHandler, that is used by @ref error() to |
278 | provide gui-independend error messages. | 278 | provide gui-independend error messages. |
279 | */ | 279 | */ |
280 | void setErrorHandler( ErrorHandler * ); | 280 | void setErrorHandler( ErrorHandler * ); |
281 | 281 | ||
282 | /** | 282 | /** |
283 | Shows gui independend error messages. | 283 | Shows gui independend error messages. |
284 | */ | 284 | */ |
285 | void error( const QString& ); | 285 | void error( const QString& ); |
286 | 286 | ||
287 | /** | 287 | /** |
288 | Query all resources to clean up their lock files | 288 | Query all resources to clean up their lock files |
289 | */ | 289 | */ |
290 | void cleanUp(); | 290 | void cleanUp(); |
291 | 291 | ||
292 | // sync stuff | 292 | // sync stuff |
293 | //Addressee::List getExternLastSyncAddressees(); | 293 | //Addressee::List getExternLastSyncAddressees(); |
294 | void resetTempSyncStat(); | 294 | void resetTempSyncStat(); |
295 | QStringList uidList(); | 295 | QStringList uidList(); |
296 | void removeSyncAddressees( bool removeDeleted = false ); | 296 | void removeSyncAddressees( bool removeDeleted = false ); |
297 | void mergeAB( AddressBook *aBook, const QString& profile ); | 297 | void mergeAB( AddressBook *aBook, const QString& profile ); |
298 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 298 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
299 | bool containsExternalUid( const QString& uid ); | 299 | bool containsExternalUid( const QString& uid ); |
300 | 300 | ||
301 | void preExternSync( AddressBook* aBook, const QString& csd ); | 301 | void preExternSync( AddressBook* aBook, const QString& csd ); |
302 | void postExternSync( AddressBook* aBook, const QString& csd ); | 302 | void postExternSync( AddressBook* aBook, const QString& csd ); |
303 | signals: | 303 | signals: |
304 | /** | 304 | /** |
305 | Emitted, when the address book has changed on disk. | 305 | Emitted, when the address book has changed on disk. |
306 | */ | 306 | */ |
307 | void addressBookChanged( AddressBook * ); | 307 | void addressBookChanged( AddressBook * ); |
308 | 308 | ||
309 | /** | 309 | /** |
310 | Emitted, when the address book has been locked for writing. | 310 | Emitted, when the address book has been locked for writing. |
311 | */ | 311 | */ |
312 | void addressBookLocked( AddressBook * ); | 312 | void addressBookLocked( AddressBook * ); |
313 | 313 | ||
314 | /** | 314 | /** |
315 | Emitted, when the address book has been unlocked. | 315 | Emitted, when the address book has been unlocked. |
316 | */ | 316 | */ |
317 | void addressBookUnlocked( AddressBook * ); | 317 | void addressBookUnlocked( AddressBook * ); |
318 | 318 | ||
319 | protected: | 319 | protected: |
320 | void deleteRemovedAddressees(); | 320 | void deleteRemovedAddressees(); |
321 | void setStandardResource( Resource * ); | 321 | void setStandardResource( Resource * ); |
322 | Resource *standardResource(); | 322 | Resource *standardResource(); |
323 | KRES::Manager<Resource> *resourceManager(); | 323 | KRES::Manager<Resource> *resourceManager(); |
324 | 324 | ||
325 | void init(const QString &config, const QString &family); | 325 | void init(const QString &config, const QString &family); |
326 | 326 | ||
327 | private: | 327 | private: |
328 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 328 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
329 | 329 | ||
330 | 330 | ||
331 | struct AddressBookData; | 331 | struct AddressBookData; |
332 | AddressBookData *d; | 332 | AddressBookData *d; |
333 | bool blockLSEchange; | 333 | bool blockLSEchange; |
334 | }; | 334 | }; |
335 | 335 | ||
336 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 336 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
337 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 337 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
338 | 338 | ||
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 19a1845..3f3d5c0 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -126,384 +126,401 @@ Addressee Addressee::copy() | |||
126 | void Addressee::detach() | 126 | void Addressee::detach() |
127 | { | 127 | { |
128 | if ( mData.count() == 1 ) return; | 128 | if ( mData.count() == 1 ) return; |
129 | *this = copy(); | 129 | *this = copy(); |
130 | } | 130 | } |
131 | 131 | ||
132 | bool Addressee::operator==( const Addressee &a ) const | 132 | bool Addressee::operator==( const Addressee &a ) const |
133 | { | 133 | { |
134 | if ( uid() != a.uid() ) return false; | 134 | if ( uid() != a.uid() ) return false; |
135 | if ( mData->name != a.mData->name ) return false; | 135 | if ( mData->name != a.mData->name ) return false; |
136 | if ( mData->formattedName != a.mData->formattedName ) return false; | 136 | if ( mData->formattedName != a.mData->formattedName ) return false; |
137 | if ( mData->familyName != a.mData->familyName ) return false; | 137 | if ( mData->familyName != a.mData->familyName ) return false; |
138 | if ( mData->givenName != a.mData->givenName ) return false; | 138 | if ( mData->givenName != a.mData->givenName ) return false; |
139 | if ( mData->additionalName != a.mData->additionalName ) return false; | 139 | if ( mData->additionalName != a.mData->additionalName ) return false; |
140 | if ( mData->prefix != a.mData->prefix ) return false; | 140 | if ( mData->prefix != a.mData->prefix ) return false; |
141 | if ( mData->suffix != a.mData->suffix ) return false; | 141 | if ( mData->suffix != a.mData->suffix ) return false; |
142 | if ( mData->nickName != a.mData->nickName ) return false; | 142 | if ( mData->nickName != a.mData->nickName ) return false; |
143 | if ( mData->birthday != a.mData->birthday ) return false; | 143 | if ( mData->birthday != a.mData->birthday ) return false; |
144 | if ( mData->mailer != a.mData->mailer ) return false; | 144 | if ( mData->mailer != a.mData->mailer ) return false; |
145 | if ( mData->timeZone != a.mData->timeZone ) return false; | 145 | if ( mData->timeZone != a.mData->timeZone ) return false; |
146 | if ( mData->geo != a.mData->geo ) return false; | 146 | if ( mData->geo != a.mData->geo ) return false; |
147 | if ( mData->title != a.mData->title ) return false; | 147 | if ( mData->title != a.mData->title ) return false; |
148 | if ( mData->role != a.mData->role ) return false; | 148 | if ( mData->role != a.mData->role ) return false; |
149 | if ( mData->organization != a.mData->organization ) return false; | 149 | if ( mData->organization != a.mData->organization ) return false; |
150 | if ( mData->note != a.mData->note ) return false; | 150 | if ( mData->note != a.mData->note ) return false; |
151 | if ( mData->productId != a.mData->productId ) return false; | 151 | if ( mData->productId != a.mData->productId ) return false; |
152 | //if ( mData->revision != a.mData->revision ) return false; | 152 | //if ( mData->revision != a.mData->revision ) return false; |
153 | if ( mData->sortString != a.mData->sortString ) return false; | 153 | if ( mData->sortString != a.mData->sortString ) return false; |
154 | if ( mData->secrecy != a.mData->secrecy ) return false; | 154 | if ( mData->secrecy != a.mData->secrecy ) return false; |
155 | if ( mData->logo != a.mData->logo ) return false; | 155 | if ( mData->logo != a.mData->logo ) return false; |
156 | if ( mData->photo != a.mData->photo ) return false; | 156 | if ( mData->photo != a.mData->photo ) return false; |
157 | if ( mData->sound != a.mData->sound ) return false; | 157 | if ( mData->sound != a.mData->sound ) return false; |
158 | if ( mData->agent != a.mData->agent ) return false; | 158 | if ( mData->agent != a.mData->agent ) return false; |
159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
160 | ( mData->url != a.mData->url ) ) return false; | 160 | ( mData->url != a.mData->url ) ) return false; |
161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
162 | if ( mData->addresses != a.mData->addresses ) return false; | 162 | if ( mData->addresses != a.mData->addresses ) return false; |
163 | if ( mData->keys != a.mData->keys ) return false; | 163 | if ( mData->keys != a.mData->keys ) return false; |
164 | if ( mData->emails != a.mData->emails ) return false; | 164 | if ( mData->emails != a.mData->emails ) return false; |
165 | if ( mData->categories != a.mData->categories ) return false; | 165 | if ( mData->categories != a.mData->categories ) return false; |
166 | if ( mData->custom != a.mData->custom ) return false; | 166 | if ( mData->custom != a.mData->custom ) return false; |
167 | 167 | ||
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | 170 | ||
171 | bool Addressee::operator!=( const Addressee &a ) const | 171 | bool Addressee::operator!=( const Addressee &a ) const |
172 | { | 172 | { |
173 | return !( a == *this ); | 173 | return !( a == *this ); |
174 | } | 174 | } |
175 | 175 | ||
176 | bool Addressee::isEmpty() const | 176 | bool Addressee::isEmpty() const |
177 | { | 177 | { |
178 | return mData->empty; | 178 | return mData->empty; |
179 | } | 179 | } |
180 | ulong Addressee::getCsum4List( const QStringList & attList) | 180 | ulong Addressee::getCsum4List( const QStringList & attList) |
181 | { | 181 | { |
182 | int max = attList.count(); | 182 | int max = attList.count(); |
183 | ulong cSum = 0; | 183 | ulong cSum = 0; |
184 | int j,k,i; | 184 | int j,k,i; |
185 | int add; | 185 | int add; |
186 | for ( i = 0; i < max ; ++i ) { | 186 | for ( i = 0; i < max ; ++i ) { |
187 | QString s = attList[i]; | 187 | QString s = attList[i]; |
188 | if ( ! s.isEmpty() ){ | 188 | if ( ! s.isEmpty() ){ |
189 | j = s.length(); | 189 | j = s.length(); |
190 | for ( k = 0; k < j; ++k ) { | 190 | for ( k = 0; k < j; ++k ) { |
191 | int mul = k +1; | 191 | int mul = k +1; |
192 | add = s[k].unicode (); | 192 | add = s[k].unicode (); |
193 | if ( k < 16 ) | 193 | if ( k < 16 ) |
194 | mul = mul * mul; | 194 | mul = mul * mul; |
195 | int ii = i+1; | 195 | int ii = i+1; |
196 | add = add * mul *ii*ii*ii; | 196 | add = add * mul *ii*ii*ii; |
197 | cSum += add; | 197 | cSum += add; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | } | 201 | } |
202 | //QString dump = attList.join(","); | 202 | //QString dump = attList.join(","); |
203 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 203 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
204 | 204 | ||
205 | return cSum; | 205 | return cSum; |
206 | 206 | ||
207 | } | 207 | } |
208 | void Addressee::computeCsum(const QString &dev) | 208 | void Addressee::computeCsum(const QString &dev) |
209 | { | 209 | { |
210 | QStringList l; | 210 | QStringList l; |
211 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 211 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
215 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 215 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
230 | // if ( !mData->logo.isEmpty() ) l.append( ); | 230 | // if ( !mData->logo.isEmpty() ) l.append( ); |
231 | //if ( !mData->photo.isEmpty() ) l.append( ); | 231 | //if ( !mData->photo.isEmpty() ) l.append( ); |
232 | //if ( !mData->sound.isEmpty() ) l.append( ); | 232 | //if ( !mData->sound.isEmpty() ) l.append( ); |
233 | //if ( !mData->agent.isEmpty() ) l.append( ); | 233 | //if ( !mData->agent.isEmpty() ) l.append( ); |
234 | //if ( mData->url.isValid() ) l.append( ); | 234 | //if ( mData->url.isValid() ) l.append( ); |
235 | #if 0 | 235 | #if 0 |
236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
237 | if ( !mData->addresses.isEmpty() ) l.append( ); | 237 | if ( !mData->addresses.isEmpty() ) l.append( ); |
238 | //if ( !mData->keys.isEmpty() ) l.append( ); | 238 | //if ( !mData->keys.isEmpty() ) l.append( ); |
239 | if ( !mData->emails.isEmpty() ) l.append( ); | 239 | if ( !mData->emails.isEmpty() ) l.append( ); |
240 | if ( !mData->categories .isEmpty() ) l.append( ); | 240 | if ( !mData->categories .isEmpty() ) l.append( ); |
241 | if ( !mData->custom.isEmpty() ) l.append( ); | 241 | if ( !mData->custom.isEmpty() ) l.append( ); |
242 | #endif | 242 | #endif |
243 | KABC::PhoneNumber::List phoneNumbers; | 243 | KABC::PhoneNumber::List phoneNumbers; |
244 | KABC::PhoneNumber::List::Iterator phoneIter; | 244 | KABC::PhoneNumber::List::Iterator phoneIter; |
245 | 245 | ||
246 | QStringList t; | 246 | QStringList t; |
247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
248 | ++phoneIter ) | 248 | ++phoneIter ) |
249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
250 | t.sort(); | 250 | t.sort(); |
251 | uint iii; | 251 | uint iii; |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->emails; | 254 | t = mData->emails; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->categories; | 258 | t = mData->categories; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | t = mData->custom; | 262 | t = mData->custom; |
263 | t.sort(); | 263 | t.sort(); |
264 | for ( iii = 0; iii < t.count(); ++iii) | 264 | for ( iii = 0; iii < t.count(); ++iii) |
265 | l.append( t[iii] ); | 265 | l.append( t[iii] ); |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
276 | setCsum( dev, QString::number (cs )); | 276 | setCsum( dev, QString::number (cs )); |
277 | } | 277 | } |
278 | 278 | ||
279 | void Addressee::mergeContact( const Addressee& ad ) | 279 | void Addressee::mergeContact( const Addressee& ad ) |
280 | { | 280 | { |
281 | 281 | ||
282 | detach(); | 282 | detach(); |
283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
291 | if ( !mData->birthday.isValid() ) | 291 | if ( !mData->birthday.isValid() ) |
292 | if ( ad.mData->birthday.isValid()) | 292 | if ( ad.mData->birthday.isValid()) |
293 | mData->birthday = ad.mData->birthday; | 293 | mData->birthday = ad.mData->birthday; |
294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
305 | 305 | ||
306 | // pending: | 306 | // pending: |
307 | // merging phonenumbers | 307 | // merging phonenumbers |
308 | // merging addresses | 308 | // merging addresses |
309 | // merging emails; | 309 | // merging emails; |
310 | // merging categories; | 310 | // merging categories; |
311 | // merging custom; | 311 | // merging custom; |
312 | // merging keys | 312 | // merging keys |
313 | qDebug("merge contact %s ", ad.uid().latin1()); | 313 | qDebug("merge contact %s ", ad.uid().latin1()); |
314 | setUid( ad.uid() ); | 314 | setUid( ad.uid() ); |
315 | setRevision( ad.revision() ); | 315 | setRevision( ad.revision() ); |
316 | } | 316 | } |
317 | 317 | ||
318 | bool Addressee::removeVoice() | ||
319 | { | ||
320 | PhoneNumber::List phoneN = phoneNumbers(); | ||
321 | PhoneNumber::List::Iterator phoneIt; | ||
322 | bool found = false; | ||
323 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | ||
324 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | ||
325 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | ||
326 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | ||
327 | insertPhoneNumber( (*phoneIt) ); | ||
328 | found = true; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | } | ||
333 | return found; | ||
334 | } | ||
318 | void Addressee::simplifyAddresses() | 335 | void Addressee::simplifyAddresses() |
319 | { | 336 | { |
320 | if ( mData->addresses.count() < 3 ) return ; | 337 | if ( mData->addresses.count() < 3 ) return ; |
321 | int count = 0; | 338 | int count = 0; |
322 | Address::List list; | 339 | Address::List list; |
323 | Address::List::Iterator it; | 340 | Address::List::Iterator it; |
324 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 341 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
325 | if ( count > 1 ) | 342 | if ( count > 1 ) |
326 | list.append( *it ); | 343 | list.append( *it ); |
327 | ++count; | 344 | ++count; |
328 | } | 345 | } |
329 | for( it = list.begin(); it != list.end(); ++it ) { | 346 | for( it = list.begin(); it != list.end(); ++it ) { |
330 | removeAddress( (*it) ); | 347 | removeAddress( (*it) ); |
331 | } | 348 | } |
332 | } | 349 | } |
333 | 350 | ||
334 | // removes all emails but the first | 351 | // removes all emails but the first |
335 | // needed by phone sync | 352 | // needed by phone sync |
336 | void Addressee::simplifyEmails() | 353 | void Addressee::simplifyEmails() |
337 | { | 354 | { |
338 | if ( mData->emails.count() == 0 ) return ; | 355 | if ( mData->emails.count() == 0 ) return ; |
339 | QString email = mData->emails.first(); | 356 | QString email = mData->emails.first(); |
340 | detach(); | 357 | detach(); |
341 | mData->emails.clear(); | 358 | mData->emails.clear(); |
342 | mData->emails.append( email ); | 359 | mData->emails.append( email ); |
343 | } | 360 | } |
344 | 361 | ||
345 | void Addressee::simplifyPhoneNumbers() | 362 | void Addressee::simplifyPhoneNumbers() |
346 | { | 363 | { |
347 | KABC::PhoneNumber::List removeNumbers; | 364 | KABC::PhoneNumber::List removeNumbers; |
348 | KABC::PhoneNumber::List::Iterator phoneIter; | 365 | KABC::PhoneNumber::List::Iterator phoneIter; |
349 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 366 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
350 | ++phoneIter ) { | 367 | ++phoneIter ) { |
351 | if ( ! ( *phoneIter ).simplifyNumber() ) | 368 | if ( ! ( *phoneIter ).simplifyNumber() ) |
352 | removeNumbers.append( ( *phoneIter ) ); | 369 | removeNumbers.append( ( *phoneIter ) ); |
353 | } | 370 | } |
354 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 371 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
355 | ++phoneIter ) { | 372 | ++phoneIter ) { |
356 | removePhoneNumber(( *phoneIter )); | 373 | removePhoneNumber(( *phoneIter )); |
357 | } | 374 | } |
358 | } | 375 | } |
359 | void Addressee::simplifyPhoneNumberTypes() | 376 | void Addressee::simplifyPhoneNumberTypes() |
360 | { | 377 | { |
361 | KABC::PhoneNumber::List::Iterator phoneIter; | 378 | KABC::PhoneNumber::List::Iterator phoneIter; |
362 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 379 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
363 | ++phoneIter ) | 380 | ++phoneIter ) |
364 | ( *phoneIter ).simplifyType(); | 381 | ( *phoneIter ).simplifyType(); |
365 | } | 382 | } |
366 | void Addressee::removeID(const QString &prof) | 383 | void Addressee::removeID(const QString &prof) |
367 | { | 384 | { |
368 | detach(); | 385 | detach(); |
369 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 386 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
370 | 387 | ||
371 | } | 388 | } |
372 | void Addressee::setID( const QString & prof , const QString & id ) | 389 | void Addressee::setID( const QString & prof , const QString & id ) |
373 | { | 390 | { |
374 | detach(); | 391 | detach(); |
375 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 392 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
376 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 393 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
377 | } | 394 | } |
378 | void Addressee::setTempSyncStat( int id ) | 395 | void Addressee::setTempSyncStat( int id ) |
379 | { | 396 | { |
380 | if ( mData->mTempSyncStat == id ) return; | 397 | if ( mData->mTempSyncStat == id ) return; |
381 | detach(); | 398 | detach(); |
382 | mData->mTempSyncStat = id; | 399 | mData->mTempSyncStat = id; |
383 | } | 400 | } |
384 | int Addressee::tempSyncStat() const | 401 | int Addressee::tempSyncStat() const |
385 | { | 402 | { |
386 | return mData->mTempSyncStat; | 403 | return mData->mTempSyncStat; |
387 | } | 404 | } |
388 | 405 | ||
389 | QString Addressee::getID( const QString & prof) | 406 | QString Addressee::getID( const QString & prof) |
390 | { | 407 | { |
391 | return KIdManager::getId ( mData->mExternalId, prof ); | 408 | return KIdManager::getId ( mData->mExternalId, prof ); |
392 | } | 409 | } |
393 | 410 | ||
394 | void Addressee::setCsum( const QString & prof , const QString & id ) | 411 | void Addressee::setCsum( const QString & prof , const QString & id ) |
395 | { | 412 | { |
396 | detach(); | 413 | detach(); |
397 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 414 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
398 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 415 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
399 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 416 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
400 | } | 417 | } |
401 | 418 | ||
402 | QString Addressee::getCsum( const QString & prof) | 419 | QString Addressee::getCsum( const QString & prof) |
403 | { | 420 | { |
404 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 421 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
405 | } | 422 | } |
406 | 423 | ||
407 | void Addressee::setIDStr( const QString & s ) | 424 | void Addressee::setIDStr( const QString & s ) |
408 | { | 425 | { |
409 | detach(); | 426 | detach(); |
410 | mData->mExternalId = s; | 427 | mData->mExternalId = s; |
411 | } | 428 | } |
412 | 429 | ||
413 | QString Addressee::IDStr() const | 430 | QString Addressee::IDStr() const |
414 | { | 431 | { |
415 | return mData->mExternalId; | 432 | return mData->mExternalId; |
416 | } | 433 | } |
417 | 434 | ||
418 | void Addressee::setExternalUID( const QString &id ) | 435 | void Addressee::setExternalUID( const QString &id ) |
419 | { | 436 | { |
420 | if ( id == mData->externalUID ) return; | 437 | if ( id == mData->externalUID ) return; |
421 | detach(); | 438 | detach(); |
422 | mData->empty = false; | 439 | mData->empty = false; |
423 | mData->externalUID = id; | 440 | mData->externalUID = id; |
424 | } | 441 | } |
425 | 442 | ||
426 | QString Addressee::externalUID() const | 443 | QString Addressee::externalUID() const |
427 | { | 444 | { |
428 | return mData->externalUID; | 445 | return mData->externalUID; |
429 | } | 446 | } |
430 | void Addressee::setOriginalExternalUID( const QString &id ) | 447 | void Addressee::setOriginalExternalUID( const QString &id ) |
431 | { | 448 | { |
432 | if ( id == mData->originalExternalUID ) return; | 449 | if ( id == mData->originalExternalUID ) return; |
433 | detach(); | 450 | detach(); |
434 | mData->empty = false; | 451 | mData->empty = false; |
435 | //qDebug("*******Set orig uid %s ", id.latin1()); | 452 | //qDebug("*******Set orig uid %s ", id.latin1()); |
436 | mData->originalExternalUID = id; | 453 | mData->originalExternalUID = id; |
437 | } | 454 | } |
438 | 455 | ||
439 | QString Addressee::originalExternalUID() const | 456 | QString Addressee::originalExternalUID() const |
440 | { | 457 | { |
441 | return mData->originalExternalUID; | 458 | return mData->originalExternalUID; |
442 | } | 459 | } |
443 | 460 | ||
444 | void Addressee::setUid( const QString &id ) | 461 | void Addressee::setUid( const QString &id ) |
445 | { | 462 | { |
446 | if ( id == mData->uid ) return; | 463 | if ( id == mData->uid ) return; |
447 | detach(); | 464 | detach(); |
448 | //qDebug("****setuid %s ", id.latin1()); | 465 | //qDebug("****setuid %s ", id.latin1()); |
449 | mData->empty = false; | 466 | mData->empty = false; |
450 | mData->uid = id; | 467 | mData->uid = id; |
451 | } | 468 | } |
452 | 469 | ||
453 | QString Addressee::uid() const | 470 | QString Addressee::uid() const |
454 | { | 471 | { |
455 | if ( mData->uid.isEmpty() ) | 472 | if ( mData->uid.isEmpty() ) |
456 | mData->uid = KApplication::randomString( 10 ); | 473 | mData->uid = KApplication::randomString( 10 ); |
457 | 474 | ||
458 | return mData->uid; | 475 | return mData->uid; |
459 | } | 476 | } |
460 | 477 | ||
461 | QString Addressee::uidLabel() | 478 | QString Addressee::uidLabel() |
462 | { | 479 | { |
463 | return i18n("Unique Identifier"); | 480 | return i18n("Unique Identifier"); |
464 | } | 481 | } |
465 | 482 | ||
466 | void Addressee::setName( const QString &name ) | 483 | void Addressee::setName( const QString &name ) |
467 | { | 484 | { |
468 | if ( name == mData->name ) return; | 485 | if ( name == mData->name ) return; |
469 | detach(); | 486 | detach(); |
470 | mData->empty = false; | 487 | mData->empty = false; |
471 | mData->name = name; | 488 | mData->name = name; |
472 | } | 489 | } |
473 | 490 | ||
474 | QString Addressee::name() const | 491 | QString Addressee::name() const |
475 | { | 492 | { |
476 | return mData->name; | 493 | return mData->name; |
477 | } | 494 | } |
478 | 495 | ||
479 | QString Addressee::nameLabel() | 496 | QString Addressee::nameLabel() |
480 | { | 497 | { |
481 | return i18n("Name"); | 498 | return i18n("Name"); |
482 | } | 499 | } |
483 | 500 | ||
484 | 501 | ||
485 | void Addressee::setFormattedName( const QString &formattedName ) | 502 | void Addressee::setFormattedName( const QString &formattedName ) |
486 | { | 503 | { |
487 | if ( formattedName == mData->formattedName ) return; | 504 | if ( formattedName == mData->formattedName ) return; |
488 | detach(); | 505 | detach(); |
489 | mData->empty = false; | 506 | mData->empty = false; |
490 | mData->formattedName = formattedName; | 507 | mData->formattedName = formattedName; |
491 | } | 508 | } |
492 | 509 | ||
493 | QString Addressee::formattedName() const | 510 | QString Addressee::formattedName() const |
494 | { | 511 | { |
495 | return mData->formattedName; | 512 | return mData->formattedName; |
496 | } | 513 | } |
497 | 514 | ||
498 | QString Addressee::formattedNameLabel() | 515 | QString Addressee::formattedNameLabel() |
499 | { | 516 | { |
500 | return i18n("Formatted Name"); | 517 | return i18n("Formatted Name"); |
501 | } | 518 | } |
502 | 519 | ||
503 | 520 | ||
504 | void Addressee::setFamilyName( const QString &familyName ) | 521 | void Addressee::setFamilyName( const QString &familyName ) |
505 | { | 522 | { |
506 | if ( familyName == mData->familyName ) return; | 523 | if ( familyName == mData->familyName ) return; |
507 | detach(); | 524 | detach(); |
508 | mData->empty = false; | 525 | mData->empty = false; |
509 | mData->familyName = familyName; | 526 | mData->familyName = familyName; |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 44f0629..9336edc 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,315 +1,316 @@ | |||
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 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class 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 | */ |
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); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad ); | 119 | void mergeContact( const Addressee& ad ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | 121 | void simplifyAddresses(); |
122 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
123 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
124 | bool removeVoice(); | ||
124 | 125 | ||
125 | /** | 126 | /** |
126 | Set unique identifier. | 127 | Set unique identifier. |
127 | */ | 128 | */ |
128 | void setUid( const QString &uid ); | 129 | void setUid( const QString &uid ); |
129 | /** | 130 | /** |
130 | Return unique identifier. | 131 | Return unique identifier. |
131 | */ | 132 | */ |
132 | QString uid() const; | 133 | QString uid() const; |
133 | /** | 134 | /** |
134 | Return translated label for uid field. | 135 | Return translated label for uid field. |
135 | */ | 136 | */ |
136 | static QString uidLabel(); | 137 | static QString uidLabel(); |
137 | 138 | ||
138 | /** | 139 | /** |
139 | Set name. | 140 | Set name. |
140 | */ | 141 | */ |
141 | void setName( const QString &name ); | 142 | void setName( const QString &name ); |
142 | /** | 143 | /** |
143 | Return name. | 144 | Return name. |
144 | */ | 145 | */ |
145 | QString name() const; | 146 | QString name() const; |
146 | /** | 147 | /** |
147 | Return translated label for name field. | 148 | Return translated label for name field. |
148 | */ | 149 | */ |
149 | static QString nameLabel(); | 150 | static QString nameLabel(); |
150 | 151 | ||
151 | /** | 152 | /** |
152 | Set formatted name. | 153 | Set formatted name. |
153 | */ | 154 | */ |
154 | void setFormattedName( const QString &formattedName ); | 155 | void setFormattedName( const QString &formattedName ); |
155 | /** | 156 | /** |
156 | Return formatted name. | 157 | Return formatted name. |
157 | */ | 158 | */ |
158 | QString formattedName() const; | 159 | QString formattedName() const; |
159 | /** | 160 | /** |
160 | Return translated label for formattedName field. | 161 | Return translated label for formattedName field. |
161 | */ | 162 | */ |
162 | static QString formattedNameLabel(); | 163 | static QString formattedNameLabel(); |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Set family name. | 166 | Set family name. |
166 | */ | 167 | */ |
167 | void setFamilyName( const QString &familyName ); | 168 | void setFamilyName( const QString &familyName ); |
168 | /** | 169 | /** |
169 | Return family name. | 170 | Return family name. |
170 | */ | 171 | */ |
171 | QString familyName() const; | 172 | QString familyName() const; |
172 | /** | 173 | /** |
173 | Return translated label for familyName field. | 174 | Return translated label for familyName field. |
174 | */ | 175 | */ |
175 | static QString familyNameLabel(); | 176 | static QString familyNameLabel(); |
176 | 177 | ||
177 | /** | 178 | /** |
178 | Set given name. | 179 | Set given name. |
179 | */ | 180 | */ |
180 | void setGivenName( const QString &givenName ); | 181 | void setGivenName( const QString &givenName ); |
181 | /** | 182 | /** |
182 | Return given name. | 183 | Return given name. |
183 | */ | 184 | */ |
184 | QString givenName() const; | 185 | QString givenName() const; |
185 | /** | 186 | /** |
186 | Return translated label for givenName field. | 187 | Return translated label for givenName field. |
187 | */ | 188 | */ |
188 | static QString givenNameLabel(); | 189 | static QString givenNameLabel(); |
189 | 190 | ||
190 | /** | 191 | /** |
191 | Set additional names. | 192 | Set additional names. |
192 | */ | 193 | */ |
193 | void setAdditionalName( const QString &additionalName ); | 194 | void setAdditionalName( const QString &additionalName ); |
194 | /** | 195 | /** |
195 | Return additional names. | 196 | Return additional names. |
196 | */ | 197 | */ |
197 | QString additionalName() const; | 198 | QString additionalName() const; |
198 | /** | 199 | /** |
199 | Return translated label for additionalName field. | 200 | Return translated label for additionalName field. |
200 | */ | 201 | */ |
201 | static QString additionalNameLabel(); | 202 | static QString additionalNameLabel(); |
202 | 203 | ||
203 | /** | 204 | /** |
204 | Set honorific prefixes. | 205 | Set honorific prefixes. |
205 | */ | 206 | */ |
206 | void setPrefix( const QString &prefix ); | 207 | void setPrefix( const QString &prefix ); |
207 | /** | 208 | /** |
208 | Return honorific prefixes. | 209 | Return honorific prefixes. |
209 | */ | 210 | */ |
210 | QString prefix() const; | 211 | QString prefix() const; |
211 | /** | 212 | /** |
212 | Return translated label for prefix field. | 213 | Return translated label for prefix field. |
213 | */ | 214 | */ |
214 | static QString prefixLabel(); | 215 | static QString prefixLabel(); |
215 | 216 | ||
216 | /** | 217 | /** |
217 | Set honorific suffixes. | 218 | Set honorific suffixes. |
218 | */ | 219 | */ |
219 | void setSuffix( const QString &suffix ); | 220 | void setSuffix( const QString &suffix ); |
220 | /** | 221 | /** |
221 | Return honorific suffixes. | 222 | Return honorific suffixes. |
222 | */ | 223 | */ |
223 | QString suffix() const; | 224 | QString suffix() const; |
224 | /** | 225 | /** |
225 | Return translated label for suffix field. | 226 | Return translated label for suffix field. |
226 | */ | 227 | */ |
227 | static QString suffixLabel(); | 228 | static QString suffixLabel(); |
228 | 229 | ||
229 | /** | 230 | /** |
230 | Set nick name. | 231 | Set nick name. |
231 | */ | 232 | */ |
232 | void setNickName( const QString &nickName ); | 233 | void setNickName( const QString &nickName ); |
233 | /** | 234 | /** |
234 | Return nick name. | 235 | Return nick name. |
235 | */ | 236 | */ |
236 | QString nickName() const; | 237 | QString nickName() const; |
237 | /** | 238 | /** |
238 | Return translated label for nickName field. | 239 | Return translated label for nickName field. |
239 | */ | 240 | */ |
240 | static QString nickNameLabel(); | 241 | static QString nickNameLabel(); |
241 | 242 | ||
242 | /** | 243 | /** |
243 | Set birthday. | 244 | Set birthday. |
244 | */ | 245 | */ |
245 | void setBirthday( const QDateTime &birthday ); | 246 | void setBirthday( const QDateTime &birthday ); |
246 | /** | 247 | /** |
247 | Return birthday. | 248 | Return birthday. |
248 | */ | 249 | */ |
249 | QDateTime birthday() const; | 250 | QDateTime birthday() const; |
250 | /** | 251 | /** |
251 | Return translated label for birthday field. | 252 | Return translated label for birthday field. |
252 | */ | 253 | */ |
253 | static QString birthdayLabel(); | 254 | static QString birthdayLabel(); |
254 | 255 | ||
255 | /** | 256 | /** |
256 | Return translated label for homeAddressStreet field. | 257 | Return translated label for homeAddressStreet field. |
257 | */ | 258 | */ |
258 | static QString homeAddressStreetLabel(); | 259 | static QString homeAddressStreetLabel(); |
259 | 260 | ||
260 | /** | 261 | /** |
261 | Return translated label for homeAddressLocality field. | 262 | Return translated label for homeAddressLocality field. |
262 | */ | 263 | */ |
263 | static QString homeAddressLocalityLabel(); | 264 | static QString homeAddressLocalityLabel(); |
264 | 265 | ||
265 | /** | 266 | /** |
266 | Return translated label for homeAddressRegion field. | 267 | Return translated label for homeAddressRegion field. |
267 | */ | 268 | */ |
268 | static QString homeAddressRegionLabel(); | 269 | static QString homeAddressRegionLabel(); |
269 | 270 | ||
270 | /** | 271 | /** |
271 | Return translated label for homeAddressPostalCode field. | 272 | Return translated label for homeAddressPostalCode field. |
272 | */ | 273 | */ |
273 | static QString homeAddressPostalCodeLabel(); | 274 | static QString homeAddressPostalCodeLabel(); |
274 | 275 | ||
275 | /** | 276 | /** |
276 | Return translated label for homeAddressCountry field. | 277 | Return translated label for homeAddressCountry field. |
277 | */ | 278 | */ |
278 | static QString homeAddressCountryLabel(); | 279 | static QString homeAddressCountryLabel(); |
279 | 280 | ||
280 | /** | 281 | /** |
281 | Return translated label for homeAddressLabel field. | 282 | Return translated label for homeAddressLabel field. |
282 | */ | 283 | */ |
283 | static QString homeAddressLabelLabel(); | 284 | static QString homeAddressLabelLabel(); |
284 | 285 | ||
285 | /** | 286 | /** |
286 | Return translated label for businessAddressStreet field. | 287 | Return translated label for businessAddressStreet field. |
287 | */ | 288 | */ |
288 | static QString businessAddressStreetLabel(); | 289 | static QString businessAddressStreetLabel(); |
289 | 290 | ||
290 | /** | 291 | /** |
291 | Return translated label for businessAddressLocality field. | 292 | Return translated label for businessAddressLocality field. |
292 | */ | 293 | */ |
293 | static QString businessAddressLocalityLabel(); | 294 | static QString businessAddressLocalityLabel(); |
294 | 295 | ||
295 | /** | 296 | /** |
296 | Return translated label for businessAddressRegion field. | 297 | Return translated label for businessAddressRegion field. |
297 | */ | 298 | */ |
298 | static QString businessAddressRegionLabel(); | 299 | static QString businessAddressRegionLabel(); |
299 | 300 | ||
300 | /** | 301 | /** |
301 | Return translated label for businessAddressPostalCode field. | 302 | Return translated label for businessAddressPostalCode field. |
302 | */ | 303 | */ |
303 | static QString businessAddressPostalCodeLabel(); | 304 | static QString businessAddressPostalCodeLabel(); |
304 | 305 | ||
305 | /** | 306 | /** |
306 | Return translated label for businessAddressCountry field. | 307 | Return translated label for businessAddressCountry field. |
307 | */ | 308 | */ |
308 | static QString businessAddressCountryLabel(); | 309 | static QString businessAddressCountryLabel(); |
309 | 310 | ||
310 | /** | 311 | /** |
311 | Return translated label for businessAddressLabel field. | 312 | Return translated label for businessAddressLabel field. |
312 | */ | 313 | */ |
313 | static QString businessAddressLabelLabel(); | 314 | static QString businessAddressLabelLabel(); |
314 | 315 | ||
315 | /** | 316 | /** |