summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 295cf03..03a86f9 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -369,97 +369,96 @@ bool AddressBook::save( Ticket *ticket )
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 outFile.close(); 402 outFile.close();
403} 403}
404void AddressBook::importFromFile( QString fileName ) 404void AddressBook::importFromFile( QString fileName )
405{ 405{
406 406
407 KABC::Addressee::List list; 407 KABC::Addressee::List list;
408 QFile file( fileName ); 408 QFile file( fileName );
409 409
410 file.open( IO_ReadOnly ); 410 file.open( IO_ReadOnly );
411 QByteArray rawData = file.readAll(); 411 QByteArray rawData = file.readAll();
412 file.close(); 412 file.close();
413 413
414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
415 KABC::VCardTool tool; 415 KABC::VCardTool tool;
416 list = tool.parseVCards( data ); 416 list = tool.parseVCards( data );
417
418 KABC::Addressee::List::Iterator it; 417 KABC::Addressee::List::Iterator it;
419 for ( it = list.begin(); it != list.end(); ++it ) { 418 for ( it = list.begin(); it != list.end(); ++it ) {
420 (*it).setResource( 0 ); 419 (*it).setResource( 0 );
421 insertAddressee( (*it), false, true ); 420 insertAddressee( (*it), false, true );
422 } 421 }
423 422
424} 423}
425 424
426bool AddressBook::saveAB() 425bool AddressBook::saveAB()
427{ 426{
428 bool ok = true; 427 bool ok = true;
429 428
430 deleteRemovedAddressees(); 429 deleteRemovedAddressees();
431 Iterator ait; 430 Iterator ait;
432 for ( ait = begin(); ait != end(); ++ait ) { 431 for ( ait = begin(); ait != end(); ++ait ) {
433 if ( !(*ait).IDStr().isEmpty() ) { 432 if ( !(*ait).IDStr().isEmpty() ) {
434 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 433 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
435 } 434 }
436 } 435 }
437 KRES::Manager<Resource>::ActiveIterator it; 436 KRES::Manager<Resource>::ActiveIterator it;
438 KRES::Manager<Resource> *manager = d->mManager; 437 KRES::Manager<Resource> *manager = d->mManager;
439 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 438 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
440 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 439 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
441 Ticket *ticket = requestSaveTicket( *it ); 440 Ticket *ticket = requestSaveTicket( *it );
442// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 441// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
443 if ( !ticket ) { 442 if ( !ticket ) {
444 error( i18n( "Unable to save to resource '%1'. It is locked." ) 443 error( i18n( "Unable to save to resource '%1'. It is locked." )
445 .arg( (*it)->resourceName() ) ); 444 .arg( (*it)->resourceName() ) );
446 return false; 445 return false;
447 } 446 }
448 447
449 //if ( !save( ticket ) ) 448 //if ( !save( ticket ) )
450 if ( ticket->resource() ) { 449 if ( ticket->resource() ) {
451 if ( ! ticket->resource()->save( ticket ) ) 450 if ( ! ticket->resource()->save( ticket ) )
452 ok = false; 451 ok = false;
453 } else 452 } else
454 ok = false; 453 ok = false;
455 454
456 } 455 }
457 } 456 }
458 return ok; 457 return ok;
459} 458}
460 459
461AddressBook::Iterator AddressBook::begin() 460AddressBook::Iterator AddressBook::begin()
462{ 461{
463 Iterator it = Iterator(); 462 Iterator it = Iterator();
464 it.d->mIt = d->mAddressees.begin(); 463 it.d->mIt = d->mAddressees.begin();
465 return it; 464 return it;