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 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
217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 217bool 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
223AddressBook::AddressBook() 223AddressBook::AddressBook()
224{ 224{
225 init(0, "contact"); 225 init(0, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config ) 228AddressBook::AddressBook( const QString &config )
229{ 229{
230 init(config, "contact"); 230 init(config, "contact");
231} 231}
232 232
233AddressBook::AddressBook( const QString &config, const QString &family ) 233AddressBook::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"
240void AddressBook::init(const QString &config, const QString &family ) 240void 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
331AddressBook::~AddressBook() 331AddressBook::~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
339bool AddressBook::load() 339bool 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
367bool AddressBook::save( Ticket *ticket ) 367bool 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}
378void AddressBook::export2File( QString fileName ) 378void 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}
405void AddressBook::importFromFile( QString fileName ) 405void 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
426bool AddressBook::saveAB() 434bool 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
461AddressBook::Iterator AddressBook::begin() 469AddressBook::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
468AddressBook::ConstIterator AddressBook::begin() const 476AddressBook::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
475AddressBook::Iterator AddressBook::end() 483AddressBook::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
482AddressBook::ConstIterator AddressBook::end() const 490AddressBook::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
489void AddressBook::clear() 497void AddressBook::clear()
490{ 498{
491 d->mAddressees.clear(); 499 d->mAddressees.clear();
492} 500}
493 501
494Ticket *AddressBook::requestSaveTicket( Resource *resource ) 502Ticket *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
517void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 525void 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
583void AddressBook::removeAddressee( const Addressee &a ) 591void 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}