summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index ff05f7e..16927e2 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -255,389 +255,397 @@ void AddressBook::init(const QString &config, const QString &family )
255 con->writeEntry( "FileName", config ); 255 con->writeEntry( "FileName", config );
256 con->writeEntry( "FileFormat", QString("vcard") ); 256 con->writeEntry( "FileFormat", QString("vcard") );
257 con->writeEntry( "ResourceIdentifier", QString("sync") ); 257 con->writeEntry( "ResourceIdentifier", QString("sync") );
258 con->writeEntry( "ResourceName", QString("sync_res") ); 258 con->writeEntry( "ResourceName", QString("sync_res") );
259 if ( config.right(4) == ".xml" ) 259 if ( config.right(4) == ".xml" )
260 con->writeEntry( "ResourceType", QString("qtopia") ); 260 con->writeEntry( "ResourceType", QString("qtopia") );
261 else if ( config == "sharp" ) { 261 else if ( config == "sharp" ) {
262 con->writeEntry( "ResourceType", QString("sharp") ); 262 con->writeEntry( "ResourceType", QString("sharp") );
263 } else { 263 } else {
264 con->writeEntry( "ResourceType", QString("file") ); 264 con->writeEntry( "ResourceType", QString("file") );
265 } 265 }
266 //con->sync(); 266 //con->sync();
267 d->mConfig = con; 267 d->mConfig = con;
268 } 268 }
269 else 269 else
270 d->mConfig = new KConfig( locateLocal("config", config) ); 270 d->mConfig = new KConfig( locateLocal("config", config) );
271// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 271// qDebug("AddressBook::init 1 config=%s",config.latin1() );
272 } 272 }
273 else { 273 else {
274 d->mConfig = 0; 274 d->mConfig = 0;
275// qDebug("AddressBook::init 1 config=0"); 275// qDebug("AddressBook::init 1 config=0");
276 } 276 }
277 277
278//US d->mErrorHandler = 0; 278//US d->mErrorHandler = 0;
279 d->mManager = new KRES::Manager<Resource>( fami, false ); 279 d->mManager = new KRES::Manager<Resource>( fami, false );
280 d->mManager->readConfig( d->mConfig ); 280 d->mManager->readConfig( d->mConfig );
281 if ( family == "syncContact" ) { 281 if ( family == "syncContact" ) {
282 KRES::Manager<Resource> *manager = d->mManager; 282 KRES::Manager<Resource> *manager = d->mManager;
283 KRES::Manager<Resource>::ActiveIterator it; 283 KRES::Manager<Resource>::ActiveIterator it;
284 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 284 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
285 (*it)->setAddressBook( this ); 285 (*it)->setAddressBook( this );
286 if ( !(*it)->open() ) 286 if ( !(*it)->open() )
287 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 287 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
288 } 288 }
289 Resource *res = standardResource(); 289 Resource *res = standardResource();
290 if ( !res ) { 290 if ( !res ) {
291 qDebug("ERROR: no standard resource"); 291 qDebug("ERROR: no standard resource");
292 res = manager->createResource( "file" ); 292 res = manager->createResource( "file" );
293 if ( res ) 293 if ( res )
294 { 294 {
295 addResource( res ); 295 addResource( res );
296 } 296 }
297 else 297 else
298 qDebug(" No resource available!!!"); 298 qDebug(" No resource available!!!");
299 } 299 }
300 setStandardResource( res ); 300 setStandardResource( res );
301 manager->writeConfig(); 301 manager->writeConfig();
302 } 302 }
303 addCustomField( i18n( "Department" ), KABC::Field::Organization, 303 addCustomField( i18n( "Department" ), KABC::Field::Organization,
304 "X-Department", "KADDRESSBOOK" ); 304 "X-Department", "KADDRESSBOOK" );
305 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 305 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
306 "X-Profession", "KADDRESSBOOK" ); 306 "X-Profession", "KADDRESSBOOK" );
307 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 307 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
308 "X-AssistantsName", "KADDRESSBOOK" ); 308 "X-AssistantsName", "KADDRESSBOOK" );
309 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 309 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
310 "X-ManagersName", "KADDRESSBOOK" ); 310 "X-ManagersName", "KADDRESSBOOK" );
311 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 311 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
312 "X-SpousesName", "KADDRESSBOOK" ); 312 "X-SpousesName", "KADDRESSBOOK" );
313 addCustomField( i18n( "Office" ), KABC::Field::Personal, 313 addCustomField( i18n( "Office" ), KABC::Field::Personal,
314 "X-Office", "KADDRESSBOOK" ); 314 "X-Office", "KADDRESSBOOK" );
315 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 315 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
316 "X-IMAddress", "KADDRESSBOOK" ); 316 "X-IMAddress", "KADDRESSBOOK" );
317 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 317 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
318 "X-Anniversary", "KADDRESSBOOK" ); 318 "X-Anniversary", "KADDRESSBOOK" );
319 319
320 //US added this field to become compatible with Opie/qtopia addressbook 320 //US added this field to become compatible with Opie/qtopia addressbook
321 // values can be "female" or "male" or "". An empty field represents undefined. 321 // values can be "female" or "male" or "". An empty field represents undefined.
322 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 322 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
323 "X-Gender", "KADDRESSBOOK" ); 323 "X-Gender", "KADDRESSBOOK" );
324 addCustomField( i18n( "Children" ), KABC::Field::Personal, 324 addCustomField( i18n( "Children" ), KABC::Field::Personal,
325 "X-Children", "KADDRESSBOOK" ); 325 "X-Children", "KADDRESSBOOK" );
326 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 326 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
327 "X-FreeBusyUrl", "KADDRESSBOOK" ); 327 "X-FreeBusyUrl", "KADDRESSBOOK" );
328 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 328 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
329 "X-ExternalID", "KADDRESSBOOK" ); 329 "X-ExternalID", "KADDRESSBOOK" );
330} 330}
331 331
332AddressBook::~AddressBook() 332AddressBook::~AddressBook()
333{ 333{
334 delete d->mConfig; d->mConfig = 0; 334 delete d->mConfig; d->mConfig = 0;
335 delete d->mManager; d->mManager = 0; 335 delete d->mManager; d->mManager = 0;
336//US delete d->mErrorHandler; d->mErrorHandler = 0; 336//US delete d->mErrorHandler; d->mErrorHandler = 0;
337 delete d; d = 0; 337 delete d; d = 0;
338} 338}
339 339
340bool AddressBook::load() 340bool AddressBook::load()
341{ 341{
342 342
343 343
344 clear(); 344 clear();
345 345
346 KRES::Manager<Resource>::ActiveIterator it; 346 KRES::Manager<Resource>::ActiveIterator it;
347 bool ok = true; 347 bool ok = true;
348 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 348 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
349 if ( !(*it)->load() ) { 349 if ( !(*it)->load() ) {
350 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 350 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
351 ok = false; 351 ok = false;
352 } 352 }
353 353
354 // mark all addressees as unchanged 354 // mark all addressees as unchanged
355 Addressee::List::Iterator addrIt; 355 Addressee::List::Iterator addrIt;
356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
357 (*addrIt).setChanged( false ); 357 (*addrIt).setChanged( false );
358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
359 if ( !id.isEmpty() ) { 359 if ( !id.isEmpty() ) {
360 //qDebug("setId aa %s ", id.latin1()); 360 //qDebug("setId aa %s ", id.latin1());
361 (*addrIt).setIDStr(id ); 361 (*addrIt).setIDStr(id );
362 } 362 }
363 } 363 }
364 blockLSEchange = true; 364 blockLSEchange = true;
365 return ok; 365 return ok;
366} 366}
367 367
368bool AddressBook::save( Ticket *ticket ) 368bool AddressBook::save( Ticket *ticket )
369{ 369{
370 kdDebug(5700) << "AddressBook::save()"<< endl; 370 kdDebug(5700) << "AddressBook::save()"<< endl;
371 371
372 if ( ticket->resource() ) { 372 if ( ticket->resource() ) {
373 deleteRemovedAddressees(); 373 deleteRemovedAddressees();
374 return ticket->resource()->save( ticket ); 374 return ticket->resource()->save( ticket );
375 } 375 }
376 376
377 return false; 377 return false;
378} 378}
379void AddressBook::export2File( QString fileName ) 379void AddressBook::export2File( QString fileName )
380{ 380{
381 381
382 QFile outFile( fileName ); 382 QFile outFile( fileName );
383 if ( !outFile.open( IO_WriteOnly ) ) { 383 if ( !outFile.open( IO_WriteOnly ) ) {
384 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 384 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
385 KMessageBox::error( 0, text.arg( fileName ) ); 385 KMessageBox::error( 0, text.arg( fileName ) );
386 return ; 386 return ;
387 } 387 }
388 QTextStream t( &outFile ); 388 QTextStream t( &outFile );
389 t.setEncoding( QTextStream::UnicodeUTF8 ); 389 t.setEncoding( QTextStream::UnicodeUTF8 );
390 Iterator it; 390 Iterator it;
391 KABC::VCardConverter::Version version; 391 KABC::VCardConverter::Version version;
392 version = KABC::VCardConverter::v3_0; 392 version = KABC::VCardConverter::v3_0;
393 for ( it = begin(); it != end(); ++it ) { 393 for ( it = begin(); it != end(); ++it ) {
394 if ( !(*it).IDStr().isEmpty() ) { 394 if ( !(*it).IDStr().isEmpty() ) {
395 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 395 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
396 } 396 }
397 KABC::VCardConverter converter; 397 KABC::VCardConverter converter;
398 QString vcard; 398 QString vcard;
399 //Resource *resource() const; 399 //Resource *resource() const;
400 converter.addresseeToVCard( *it, vcard, version ); 400 converter.addresseeToVCard( *it, vcard, version );
401 t << vcard << "\r\n"; 401 t << vcard << "\r\n";
402 } 402 }
403 t << "\r\n\r\n"; 403 t << "\r\n\r\n";
404 outFile.close(); 404 outFile.close();
405} 405}
406void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 406void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
407{ 407{
408 408
409 if ( removeOld ) 409 if ( removeOld )
410 setUntagged(); 410 setUntagged();
411 KABC::Addressee::List list; 411 KABC::Addressee::List list;
412 QFile file( fileName ); 412 QFile file( fileName );
413 file.open( IO_ReadOnly ); 413 file.open( IO_ReadOnly );
414 QByteArray rawData = file.readAll(); 414 QByteArray rawData = file.readAll();
415 file.close(); 415 file.close();
416 QString data; 416 QString data;
417 if ( replaceLabel ) { 417 if ( replaceLabel ) {
418 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 418 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
419 data.replace ( QRegExp("LABEL") , "ADR" ); 419 data.replace ( QRegExp("LABEL") , "ADR" );
420 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 420 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
421 } else 421 } else
422 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 422 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
423 KABC::VCardTool tool; 423 KABC::VCardTool tool;
424 list = tool.parseVCards( data ); 424 list = tool.parseVCards( data );
425 KABC::Addressee::List::Iterator it; 425 KABC::Addressee::List::Iterator it;
426 for ( it = list.begin(); it != list.end(); ++it ) { 426 for ( it = list.begin(); it != list.end(); ++it ) {
427 (*it).setResource( 0 ); 427 (*it).setResource( 0 );
428 if ( replaceLabel ) 428 if ( replaceLabel )
429 (*it).removeVoice(); 429 (*it).removeVoice();
430 if ( removeOld ) 430 if ( removeOld )
431 (*it).setTagged( true ); 431 (*it).setTagged( true );
432 insertAddressee( (*it), false, true ); 432 insertAddressee( (*it), false, true );
433 } 433 }
434 if ( removeOld ) 434 if ( removeOld )
435 removeUntagged(); 435 removeUntagged();
436} 436}
437void AddressBook::setUntagged() 437void AddressBook::setUntagged()
438{ 438{
439 Iterator ait; 439 Iterator ait;
440 for ( ait = begin(); ait != end(); ++ait ) { 440 for ( ait = begin(); ait != end(); ++ait ) {
441 (*ait).setTagged( false ); 441 (*ait).setTagged( false );
442 } 442 }
443} 443}
444void AddressBook::removeUntagged() 444void AddressBook::removeUntagged()
445{ 445{
446 Iterator ait; 446 Iterator ait;
447 bool todelete = false;
448 Iterator todel;
447 for ( ait = begin(); ait != end(); ++ait ) { 449 for ( ait = begin(); ait != end(); ++ait ) {
448 if (!(*ait).tagged()) 450 if ( todelete )
449 removeAddressee( ait ); 451 removeAddressee( todel );
450 } 452 if (!(*ait).tagged()) {
451 453 todelete = true;
454 todel = ait;
455 } else
456 todelete = false;
457 }
458 if ( todelete )
459 removeAddressee( todel );
452 deleteRemovedAddressees(); 460 deleteRemovedAddressees();
453} 461}
454bool AddressBook::saveAB() 462bool AddressBook::saveAB()
455{ 463{
456 bool ok = true; 464 bool ok = true;
457 465
458 deleteRemovedAddressees(); 466 deleteRemovedAddressees();
459 Iterator ait; 467 Iterator ait;
460 for ( ait = begin(); ait != end(); ++ait ) { 468 for ( ait = begin(); ait != end(); ++ait ) {
461 if ( !(*ait).IDStr().isEmpty() ) { 469 if ( !(*ait).IDStr().isEmpty() ) {
462 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 470 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
463 } 471 }
464 } 472 }
465 KRES::Manager<Resource>::ActiveIterator it; 473 KRES::Manager<Resource>::ActiveIterator it;
466 KRES::Manager<Resource> *manager = d->mManager; 474 KRES::Manager<Resource> *manager = d->mManager;
467 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 475 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
468 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 476 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
469 Ticket *ticket = requestSaveTicket( *it ); 477 Ticket *ticket = requestSaveTicket( *it );
470// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 478// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
471 if ( !ticket ) { 479 if ( !ticket ) {
472 error( i18n( "Unable to save to resource '%1'. It is locked." ) 480 error( i18n( "Unable to save to resource '%1'. It is locked." )
473 .arg( (*it)->resourceName() ) ); 481 .arg( (*it)->resourceName() ) );
474 return false; 482 return false;
475 } 483 }
476 484
477 //if ( !save( ticket ) ) 485 //if ( !save( ticket ) )
478 if ( ticket->resource() ) { 486 if ( ticket->resource() ) {
479 if ( ! ticket->resource()->save( ticket ) ) 487 if ( ! ticket->resource()->save( ticket ) )
480 ok = false; 488 ok = false;
481 } else 489 } else
482 ok = false; 490 ok = false;
483 491
484 } 492 }
485 } 493 }
486 return ok; 494 return ok;
487} 495}
488 496
489AddressBook::Iterator AddressBook::begin() 497AddressBook::Iterator AddressBook::begin()
490{ 498{
491 Iterator it = Iterator(); 499 Iterator it = Iterator();
492 it.d->mIt = d->mAddressees.begin(); 500 it.d->mIt = d->mAddressees.begin();
493 return it; 501 return it;
494} 502}
495 503
496AddressBook::ConstIterator AddressBook::begin() const 504AddressBook::ConstIterator AddressBook::begin() const
497{ 505{
498 ConstIterator it = ConstIterator(); 506 ConstIterator it = ConstIterator();
499 it.d->mIt = d->mAddressees.begin(); 507 it.d->mIt = d->mAddressees.begin();
500 return it; 508 return it;
501} 509}
502 510
503AddressBook::Iterator AddressBook::end() 511AddressBook::Iterator AddressBook::end()
504{ 512{
505 Iterator it = Iterator(); 513 Iterator it = Iterator();
506 it.d->mIt = d->mAddressees.end(); 514 it.d->mIt = d->mAddressees.end();
507 return it; 515 return it;
508} 516}
509 517
510AddressBook::ConstIterator AddressBook::end() const 518AddressBook::ConstIterator AddressBook::end() const
511{ 519{
512 ConstIterator it = ConstIterator(); 520 ConstIterator it = ConstIterator();
513 it.d->mIt = d->mAddressees.end(); 521 it.d->mIt = d->mAddressees.end();
514 return it; 522 return it;
515} 523}
516 524
517void AddressBook::clear() 525void AddressBook::clear()
518{ 526{
519 d->mAddressees.clear(); 527 d->mAddressees.clear();
520} 528}
521 529
522Ticket *AddressBook::requestSaveTicket( Resource *resource ) 530Ticket *AddressBook::requestSaveTicket( Resource *resource )
523{ 531{
524 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 532 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
525 533
526 if ( !resource ) 534 if ( !resource )
527 { 535 {
528 qDebug("AddressBook::requestSaveTicket no resource" ); 536 qDebug("AddressBook::requestSaveTicket no resource" );
529 resource = standardResource(); 537 resource = standardResource();
530 } 538 }
531 539
532 KRES::Manager<Resource>::ActiveIterator it; 540 KRES::Manager<Resource>::ActiveIterator it;
533 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 541 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
534 if ( (*it) == resource ) { 542 if ( (*it) == resource ) {
535 if ( (*it)->readOnly() || !(*it)->isOpen() ) 543 if ( (*it)->readOnly() || !(*it)->isOpen() )
536 return 0; 544 return 0;
537 else 545 else
538 return (*it)->requestSaveTicket(); 546 return (*it)->requestSaveTicket();
539 } 547 }
540 } 548 }
541 549
542 return 0; 550 return 0;
543} 551}
544 552
545void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 553void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
546{ 554{
547 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 555 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
548 //qDebug("block insert "); 556 //qDebug("block insert ");
549 return; 557 return;
550 } 558 }
551 //qDebug("inserting.... %s ",a.uid().latin1() ); 559 //qDebug("inserting.... %s ",a.uid().latin1() );
552 bool found = false; 560 bool found = false;
553 Addressee::List::Iterator it; 561 Addressee::List::Iterator it;
554 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 562 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
555 if ( a.uid() == (*it).uid() ) { 563 if ( a.uid() == (*it).uid() ) {
556 564
557 bool changed = false; 565 bool changed = false;
558 Addressee addr = a; 566 Addressee addr = a;
559 if ( addr != (*it) ) 567 if ( addr != (*it) )
560 changed = true; 568 changed = true;
561 569
562 if ( takeResource ) { 570 if ( takeResource ) {
563 Resource * res = (*it).resource(); 571 Resource * res = (*it).resource();
564 (*it) = a; 572 (*it) = a;
565 (*it).setResource( res ); 573 (*it).setResource( res );
566 } else { 574 } else {
567 (*it) = a; 575 (*it) = a;
568 if ( (*it).resource() == 0 ) 576 if ( (*it).resource() == 0 )
569 (*it).setResource( standardResource() ); 577 (*it).setResource( standardResource() );
570 } 578 }
571 if ( changed ) { 579 if ( changed ) {
572 if ( setRev ) { 580 if ( setRev ) {
573 581
574 // get rid of micro seconds 582 // get rid of micro seconds
575 QDateTime dt = QDateTime::currentDateTime(); 583 QDateTime dt = QDateTime::currentDateTime();
576 QTime t = dt.time(); 584 QTime t = dt.time();
577 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 585 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
578 (*it).setRevision( dt ); 586 (*it).setRevision( dt );
579 } 587 }
580 (*it).setChanged( true ); 588 (*it).setChanged( true );
581 } 589 }
582 590
583 found = true; 591 found = true;
584 } else { 592 } else {
585 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 593 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
586 QString name = (*it).uid().mid( 19 ); 594 QString name = (*it).uid().mid( 19 );
587 Addressee b = a; 595 Addressee b = a;
588 QString id = b.getID( name ); 596 QString id = b.getID( name );
589 if ( ! id.isEmpty() ) { 597 if ( ! id.isEmpty() ) {
590 QString des = (*it).note(); 598 QString des = (*it).note();
591 int startN; 599 int startN;
592 if( (startN = des.find( id ) ) >= 0 ) { 600 if( (startN = des.find( id ) ) >= 0 ) {
593 int endN = des.find( ",", startN+1 ); 601 int endN = des.find( ",", startN+1 );
594 des = des.left( startN ) + des.mid( endN+1 ); 602 des = des.left( startN ) + des.mid( endN+1 );
595 (*it).setNote( des ); 603 (*it).setNote( des );
596 } 604 }
597 } 605 }
598 } 606 }
599 } 607 }
600 } 608 }
601 if ( found ) 609 if ( found )
602 return; 610 return;
603 d->mAddressees.append( a ); 611 d->mAddressees.append( a );
604 Addressee& addr = d->mAddressees.last(); 612 Addressee& addr = d->mAddressees.last();
605 if ( addr.resource() == 0 ) 613 if ( addr.resource() == 0 )
606 addr.setResource( standardResource() ); 614 addr.setResource( standardResource() );
607 615
608 addr.setChanged( true ); 616 addr.setChanged( true );
609} 617}
610 618
611void AddressBook::removeAddressee( const Addressee &a ) 619void AddressBook::removeAddressee( const Addressee &a )
612{ 620{
613 Iterator it; 621 Iterator it;
614 Iterator it2; 622 Iterator it2;
615 bool found = false; 623 bool found = false;
616 for ( it = begin(); it != end(); ++it ) { 624 for ( it = begin(); it != end(); ++it ) {
617 if ( a.uid() == (*it).uid() ) { 625 if ( a.uid() == (*it).uid() ) {
618 found = true; 626 found = true;
619 it2 = it; 627 it2 = it;
620 } else { 628 } else {
621 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 629 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
622 QString name = (*it).uid().mid( 19 ); 630 QString name = (*it).uid().mid( 19 );
623 Addressee b = a; 631 Addressee b = a;
624 QString id = b.getID( name ); 632 QString id = b.getID( name );
625 if ( ! id.isEmpty() ) { 633 if ( ! id.isEmpty() ) {
626 QString des = (*it).note(); 634 QString des = (*it).note();
627 if( des.find( id ) < 0 ) { 635 if( des.find( id ) < 0 ) {
628 des += id + ","; 636 des += id + ",";
629 (*it).setNote( des ); 637 (*it).setNote( des );
630 } 638 }
631 } 639 }
632 } 640 }
633 641
634 } 642 }
635 } 643 }
636 644
637 if ( found ) 645 if ( found )
638 removeAddressee( it2 ); 646 removeAddressee( it2 );
639 647
640} 648}
641 649
642void AddressBook::removeSyncAddressees( bool removeDeleted ) 650void AddressBook::removeSyncAddressees( bool removeDeleted )
643{ 651{