summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-14 07:24:50 (UTC)
committer zautrix <zautrix>2004-10-14 07:24:50 (UTC)
commit57bd80b04dddd40a897dce8b6902d1046d71c631 (patch) (unidiff)
treec51cb1985344173951109f4bffb12bb6a68ea7f7
parenta6dff815a9c6d3a91094573d23c28a8553fc7cc2 (diff)
downloadkdepimpi-57bd80b04dddd40a897dce8b6902d1046d71c631.zip
kdepimpi-57bd80b04dddd40a897dce8b6902d1046d71c631.tar.gz
kdepimpi-57bd80b04dddd40a897dce8b6902d1046d71c631.tar.bz2
phone fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp22
-rw-r--r--kaddressbook/kabcore.cpp45
-rw-r--r--kaddressbook/kabcore.h2
3 files changed, 41 insertions, 28 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 295ee4f..2564894 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -354,199 +354,217 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
354 } 354 }
355 } 355 }
356 if ( !mData->agent.isIntern() ) { 356 if ( !mData->agent.isIntern() ) {
357 if ( mData->agent.url().isEmpty() ) { 357 if ( mData->agent.url().isEmpty() ) {
358 mData->agent = ad.mData->agent; 358 mData->agent = ad.mData->agent;
359 } 359 }
360 } 360 }
361 { 361 {
362 Key::List::Iterator itA; 362 Key::List::Iterator itA;
363 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 363 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
364 bool found = false; 364 bool found = false;
365 Key::List::Iterator it; 365 Key::List::Iterator it;
366 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 366 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
367 if ( (*it) == (*itA)) { 367 if ( (*it) == (*itA)) {
368 found = true; 368 found = true;
369 break; 369 break;
370 370
371 } 371 }
372 } 372 }
373 if ( ! found ) { 373 if ( ! found ) {
374 mData->keys.append( *itA ); 374 mData->keys.append( *itA );
375 } 375 }
376 } 376 }
377 } 377 }
378 KABC::Address::List::Iterator addressIterA; 378 KABC::Address::List::Iterator addressIterA;
379 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 379 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
380 bool found = false; 380 bool found = false;
381 KABC::Address::List::Iterator addressIter; 381 KABC::Address::List::Iterator addressIter;
382 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 382 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
383 ++addressIter ) { 383 ++addressIter ) {
384 if ( (*addressIter) == (*addressIterA)) { 384 if ( (*addressIter) == (*addressIterA)) {
385 found = true; 385 found = true;
386 (*addressIter).setType( (*addressIterA).type() ); 386 (*addressIter).setType( (*addressIterA).type() );
387 break; 387 break;
388 } 388 }
389 389
390 } 390 }
391 if ( isSubSet && ! found ) { 391 if ( isSubSet && ! found ) {
392 mData->addresses.append( *addressIterA ); 392 mData->addresses.append( *addressIterA );
393 } 393 }
394 } 394 }
395 //qDebug("merge contact %s ", ad.uid().latin1()); 395 //qDebug("merge contact %s ", ad.uid().latin1());
396 setUid( ad.uid() ); 396 setUid( ad.uid() );
397 setRevision( ad.revision() ); 397 setRevision( ad.revision() );
398} 398}
399 399
400bool Addressee::removeVoice() 400bool Addressee::removeVoice()
401{ 401{
402 PhoneNumber::List phoneN = phoneNumbers(); 402 PhoneNumber::List phoneN = phoneNumbers();
403 PhoneNumber::List::Iterator phoneIt; 403 PhoneNumber::List::Iterator phoneIt;
404 bool found = false; 404 bool found = false;
405 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 405 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
406 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 406 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
407 if ((*phoneIt).type() - PhoneNumber::Voice ) { 407 if ((*phoneIt).type() - PhoneNumber::Voice ) {
408 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 408 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
409 insertPhoneNumber( (*phoneIt) ); 409 insertPhoneNumber( (*phoneIt) );
410 found = true; 410 found = true;
411 } 411 }
412 } 412 }
413 413
414 } 414 }
415 return found; 415 return found;
416} 416}
417 417
418bool Addressee::containsAdr(const Addressee& ad ) 418bool Addressee::containsAdr(const Addressee& ad )
419{ 419{
420 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 420 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
421 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 421 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
422 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 422 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
423 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 423 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
424 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 424 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
425 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 425 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
426 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 426 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
427 427
428 // compare phone numbers 428 // compare phone numbers
429 PhoneNumber::List phoneN = ad.phoneNumbers(); 429 PhoneNumber::List phoneN = ad.phoneNumbers();
430 PhoneNumber::List::Iterator phoneIt; 430 PhoneNumber::List::Iterator phoneIt;
431 bool found = false; 431 bool found = false;
432 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 432 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
433 bool found = false; 433 bool found = false;
434 PhoneNumber::List phoneL = ad.phoneNumbers(); 434 PhoneNumber::List phoneL = ad.phoneNumbers();
435 PhoneNumber::List::Iterator phoneItL; 435 PhoneNumber::List::Iterator phoneItL;
436 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 436 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
437 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 437 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
438 found = true; 438 found = true;
439 break; 439 break;
440 } 440 }
441 } 441 }
442 if ( ! found ) 442 if ( ! found )
443 return false; 443 return false;
444 } 444 }
445 return true; 445 return true;
446 446
447} 447}
448void Addressee::simplifyAddresses() 448void Addressee::simplifyAddresses()
449{ 449{
450
451
452 Address::List list;
453 Address::List::Iterator it;
454 Address::List::Iterator it2;
455 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
456 it2 = it;
457 ++it2;
458 for( ; it2 != mData->addresses.end(); ++it2 ) {
459 if ( (*it) == (*it2) ) {
460 list.append( *it );
461 break;
462 }
463 }
464 }
465 for( it = list.begin(); it != list.end(); ++it ) {
466 removeAddress( (*it) );
467 }
468
469 list.clear();
450 int max = 2; 470 int max = 2;
451 if ( mData->url.isValid() ) 471 if ( mData->url.isValid() )
452 max = 1; 472 max = 1;
453 if ( mData->addresses.count() <= max ) return ; 473 if ( mData->addresses.count() <= max ) return ;
454 int count = 0; 474 int count = 0;
455 Address::List list;
456 Address::List::Iterator it;
457 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 475 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
458 if ( count >= max ) 476 if ( count >= max )
459 list.append( *it ); 477 list.append( *it );
460 ++count; 478 ++count;
461 } 479 }
462 for( it = list.begin(); it != list.end(); ++it ) { 480 for( it = list.begin(); it != list.end(); ++it ) {
463 removeAddress( (*it) ); 481 removeAddress( (*it) );
464 } 482 }
465} 483}
466 484
467// removes all emails but the first 485// removes all emails but the first
468// needed by phone sync 486// needed by phone sync
469void Addressee::simplifyEmails() 487void Addressee::simplifyEmails()
470{ 488{
471 if ( mData->emails.count() == 0 ) return ; 489 if ( mData->emails.count() == 0 ) return ;
472 QString email = mData->emails.first(); 490 QString email = mData->emails.first();
473 detach(); 491 detach();
474 mData->emails.clear(); 492 mData->emails.clear();
475 mData->emails.append( email ); 493 mData->emails.append( email );
476} 494}
477 495
478void Addressee::simplifyPhoneNumbers() 496void Addressee::simplifyPhoneNumbers()
479{ 497{
480 int max = 4; 498 int max = 4;
481 int inList = mData->phoneNumbers.count(); 499 int inList = mData->phoneNumbers.count();
482 KABC::PhoneNumber::List removeNumbers; 500 KABC::PhoneNumber::List removeNumbers;
483 KABC::PhoneNumber::List::Iterator phoneIter; 501 KABC::PhoneNumber::List::Iterator phoneIter;
484 if ( inList > max ) { 502 if ( inList > max ) {
485 // delete non-preferred numbers 503 // delete non-preferred numbers
486 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 504 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
487 ++phoneIter ) { 505 ++phoneIter ) {
488 if ( inList > max ) { 506 if ( inList > max ) {
489 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 507 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
490 removeNumbers.append( ( *phoneIter ) ); 508 removeNumbers.append( ( *phoneIter ) );
491 --inList; 509 --inList;
492 } 510 }
493 } else 511 } else
494 break; 512 break;
495 } 513 }
496 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 514 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
497 ++phoneIter ) { 515 ++phoneIter ) {
498 removePhoneNumber(( *phoneIter )); 516 removePhoneNumber(( *phoneIter ));
499 } 517 }
500 // delete preferred numbers 518 // delete preferred numbers
501 if ( inList > max ) { 519 if ( inList > max ) {
502 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 520 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
503 ++phoneIter ) { 521 ++phoneIter ) {
504 if ( inList > max ) { 522 if ( inList > max ) {
505 removeNumbers.append( ( *phoneIter ) ); 523 removeNumbers.append( ( *phoneIter ) );
506 --inList; 524 --inList;
507 } else 525 } else
508 break; 526 break;
509 } 527 }
510 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 528 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
511 ++phoneIter ) { 529 ++phoneIter ) {
512 removePhoneNumber(( *phoneIter )); 530 removePhoneNumber(( *phoneIter ));
513 } 531 }
514 } 532 }
515 } 533 }
516 // remove non-numeric characters 534 // remove non-numeric characters
517 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 535 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
518 ++phoneIter ) { 536 ++phoneIter ) {
519 if ( ! ( *phoneIter ).simplifyNumber() ) 537 if ( ! ( *phoneIter ).simplifyNumber() )
520 removeNumbers.append( ( *phoneIter ) ); 538 removeNumbers.append( ( *phoneIter ) );
521 } 539 }
522 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 540 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
523 ++phoneIter ) { 541 ++phoneIter ) {
524 removePhoneNumber(( *phoneIter )); 542 removePhoneNumber(( *phoneIter ));
525 } 543 }
526} 544}
527void Addressee::simplifyPhoneNumberTypes() 545void Addressee::simplifyPhoneNumberTypes()
528{ 546{
529 KABC::PhoneNumber::List::Iterator phoneIter; 547 KABC::PhoneNumber::List::Iterator phoneIter;
530 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 548 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
531 ++phoneIter ) 549 ++phoneIter )
532 ( *phoneIter ).simplifyType(); 550 ( *phoneIter ).simplifyType();
533} 551}
534void Addressee::removeID(const QString &prof) 552void Addressee::removeID(const QString &prof)
535{ 553{
536 detach(); 554 detach();
537 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 555 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
538 556
539} 557}
540void Addressee::setID( const QString & prof , const QString & id ) 558void Addressee::setID( const QString & prof , const QString & id )
541{ 559{
542 detach(); 560 detach();
543 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 561 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
544 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 562 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
545} 563}
546void Addressee::setTempSyncStat( int id ) 564void Addressee::setTempSyncStat( int id )
547{ 565{
548 if ( mData->mTempSyncStat == id ) return; 566 if ( mData->mTempSyncStat == id ) return;
549 detach(); 567 detach();
550 mData->mTempSyncStat = id; 568 mData->mTempSyncStat = id;
551} 569}
552int Addressee::tempSyncStat() const 570int Addressee::tempSyncStat() const
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index dae9cd2..087e9e3 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -600,333 +600,331 @@ void KABCore::mailVCard()
600void KABCore::mailVCard( const QStringList& uids ) 600void KABCore::mailVCard( const QStringList& uids )
601{ 601{
602 QStringList urls; 602 QStringList urls;
603 603
604// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 604// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
605 605
606 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 606 QString dirName = "/tmp/" + KApplication::randomString( 8 );
607 607
608 608
609 609
610 QDir().mkdir( dirName, true ); 610 QDir().mkdir( dirName, true );
611 611
612 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 612 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
613 KABC::Addressee a = mAddressBook->findByUid( *it ); 613 KABC::Addressee a = mAddressBook->findByUid( *it );
614 614
615 if ( a.isEmpty() ) 615 if ( a.isEmpty() )
616 continue; 616 continue;
617 617
618 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 618 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
619 619
620 QString fileName = dirName + "/" + name; 620 QString fileName = dirName + "/" + name;
621 621
622 QFile outFile(fileName); 622 QFile outFile(fileName);
623 623
624 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 624 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
625 KABC::VCardConverter converter; 625 KABC::VCardConverter converter;
626 QString vcard; 626 QString vcard;
627 627
628 converter.addresseeToVCard( a, vcard ); 628 converter.addresseeToVCard( a, vcard );
629 629
630 QTextStream t( &outFile ); // use a text stream 630 QTextStream t( &outFile ); // use a text stream
631 t.setEncoding( QTextStream::UnicodeUTF8 ); 631 t.setEncoding( QTextStream::UnicodeUTF8 );
632 t << vcard; 632 t << vcard;
633 633
634 outFile.close(); 634 outFile.close();
635 635
636 urls.append( fileName ); 636 urls.append( fileName );
637 } 637 }
638 } 638 }
639 639
640 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 640 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
641 641
642 642
643/*US 643/*US
644 kapp->invokeMailer( QString::null, QString::null, QString::null, 644 kapp->invokeMailer( QString::null, QString::null, QString::null,
645 QString::null, // subject 645 QString::null, // subject
646 QString::null, // body 646 QString::null, // body
647 QString::null, 647 QString::null,
648 urls ); // attachments 648 urls ); // attachments
649*/ 649*/
650 650
651} 651}
652 652
653/** 653/**
654 Beams the "WhoAmI contact. 654 Beams the "WhoAmI contact.
655*/ 655*/
656void KABCore::beamMySelf() 656void KABCore::beamMySelf()
657{ 657{
658 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 658 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
659 if (!a.isEmpty()) 659 if (!a.isEmpty())
660 { 660 {
661 QStringList uids; 661 QStringList uids;
662 uids << a.uid(); 662 uids << a.uid();
663 663
664 beamVCard(uids); 664 beamVCard(uids);
665 } else { 665 } else {
666 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 666 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
667 667
668 668
669 } 669 }
670} 670}
671 671
672void KABCore::export2phone() 672void KABCore::export2phone()
673{ 673{
674 674
675 KAex2phonePrefs ex2phone; 675 KAex2phonePrefs ex2phone;
676 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 676 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
677 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 677 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
678 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 678 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
679 679
680 if ( !ex2phone.exec() ) { 680 if ( !ex2phone.exec() ) {
681 return; 681 return;
682 } 682 }
683 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 683 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
684 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 684 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
685 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 685 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
686 686
687 687
688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
689 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 689 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
690 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 690 KPimGlobalPrefs::instance()->mEx2PhoneModel );
691 691
692 QStringList uids = mViewManager->selectedUids(); 692 QStringList uids = mViewManager->selectedUids();
693 if ( uids.isEmpty() ) 693 if ( uids.isEmpty() )
694 return; 694 return;
695 695
696 QString fileName = getPhoneFile();
697 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
698 return;
699
700 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
701
702}
703QString KABCore::getPhoneFile()
704{
696#ifdef _WIN32_ 705#ifdef _WIN32_
697 QString fileName = locateLocal("tmp", "phonefile.vcf"); 706 return locateLocal("tmp", "phonefile.vcf");
698#else 707#else
699 QString fileName = "/tmp/phonefile.vcf"; 708 return "/tmp/phonefile.vcf";
700#endif 709#endif
701 710
702 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 711}
703 return; 712void KABCore::writeToPhone( )
704 713{
705 if ( PhoneAccess::writeToPhone( fileName ) ) 714 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
706 qDebug("Export okay "); 715 qDebug("Export okay ");
707 else
708 qDebug("Error export contacts ");
709
710
711#if 0
712
713 setCaption( i18n("Writing to phone..."));
714 if ( PhoneFormat::writeToPhone( cal ) )
715 setCaption( i18n("Export to phone successful!"));
716 else 716 else
717 setCaption( i18n("Error exporting to phone!")); 717 qDebug("Error export contacts ");
718#endif
719
720
721} 718}
722void KABCore::beamVCard() 719void KABCore::beamVCard()
723{ 720{
724 QStringList uids = mViewManager->selectedUids(); 721 QStringList uids = mViewManager->selectedUids();
725 if ( !uids.isEmpty() ) 722 if ( !uids.isEmpty() )
726 beamVCard( uids ); 723 beamVCard( uids );
727} 724}
728 725
729 726
730void KABCore::beamVCard(const QStringList& uids) 727void KABCore::beamVCard(const QStringList& uids)
731{ 728{
732/*US 729/*US
733 QString beamFilename; 730 QString beamFilename;
734 Opie::OPimContact c; 731 Opie::OPimContact c;
735 if ( actionPersonal->isOn() ) { 732 if ( actionPersonal->isOn() ) {
736 beamFilename = addressbookPersonalVCardName(); 733 beamFilename = addressbookPersonalVCardName();
737 if ( !QFile::exists( beamFilename ) ) 734 if ( !QFile::exists( beamFilename ) )
738 return; // can't beam a non-existent file 735 return; // can't beam a non-existent file
739 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 736 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
740 beamFilename ); 737 beamFilename );
741 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 738 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
742 Opie::OPimContactAccess::List allList = access->allRecords(); 739 Opie::OPimContactAccess::List allList = access->allRecords();
743 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 740 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
744 c = *it; 741 c = *it;
745 742
746 delete access; 743 delete access;
747 } else { 744 } else {
748 unlink( beamfile ); // delete if exists 745 unlink( beamfile ); // delete if exists
749 mkdir("/tmp/obex/", 0755); 746 mkdir("/tmp/obex/", 0755);
750 c = m_abView -> currentEntry(); 747 c = m_abView -> currentEntry();
751 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 748 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
752 beamfile ); 749 beamfile );
753 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 750 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
754 access->add( c ); 751 access->add( c );
755 access->save(); 752 access->save();
756 delete access; 753 delete access;
757 754
758 beamFilename = beamfile; 755 beamFilename = beamfile;
759 } 756 }
760 757
761 owarn << "Beaming: " << beamFilename << oendl; 758 owarn << "Beaming: " << beamFilename << oendl;
762*/ 759*/
763 760
764#if 0 761#if 0
765 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 762 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
766 763
767 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 764 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
768 765
769 QString name = "contact.vcf"; 766 QString name = "contact.vcf";
770 767
771 QString fileName = dirName + "/" + name; 768 QString fileName = dirName + "/" + name;
772#endif 769#endif
773 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 770 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
774 // 771 //
775 QString fileName = "/tmp/kapibeamfile.vcf"; 772 QString fileName = "/tmp/kapibeamfile.vcf";
776 773
777 774
778 //QDir().mkdir( dirName, true ); 775 //QDir().mkdir( dirName, true );
779 776
780 777
781 KABC::VCardConverter converter; 778 KABC::VCardConverter converter;
782 QString description; 779 QString description;
783 QString datastream; 780 QString datastream;
784 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 781 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
785 KABC::Addressee a = mAddressBook->findByUid( *it ); 782 KABC::Addressee a = mAddressBook->findByUid( *it );
786 783
787 if ( a.isEmpty() ) 784 if ( a.isEmpty() )
788 continue; 785 continue;
789 786
790 if (description.isEmpty()) 787 if (description.isEmpty())
791 description = a.formattedName(); 788 description = a.formattedName();
792 789
793 QString vcard; 790 QString vcard;
794 converter.addresseeToVCard( a, vcard ); 791 converter.addresseeToVCard( a, vcard );
795 int start = 0; 792 int start = 0;
796 int next; 793 int next;
797 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 794 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
798 int semi = vcard.find(";", next); 795 int semi = vcard.find(";", next);
799 int dopp = vcard.find(":", next); 796 int dopp = vcard.find(":", next);
800 int sep; 797 int sep;
801 if ( semi < dopp && semi >= 0 ) 798 if ( semi < dopp && semi >= 0 )
802 sep = semi ; 799 sep = semi ;
803 else 800 else
804 sep = dopp; 801 sep = dopp;
805 datastream +=vcard.mid( start, next - start); 802 datastream +=vcard.mid( start, next - start);
806 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 803 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
807 start = sep; 804 start = sep;
808 } 805 }
809 datastream += vcard.mid( start,vcard.length() ); 806 datastream += vcard.mid( start,vcard.length() );
810 } 807 }
811#ifndef DESKTOP_VERSION 808#ifndef DESKTOP_VERSION
812 QFile outFile(fileName); 809 QFile outFile(fileName);
813 if ( outFile.open(IO_WriteOnly) ) { 810 if ( outFile.open(IO_WriteOnly) ) {
814 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 811 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
815 QTextStream t( &outFile ); // use a text stream 812 QTextStream t( &outFile ); // use a text stream
816 //t.setEncoding( QTextStream::UnicodeUTF8 ); 813 //t.setEncoding( QTextStream::UnicodeUTF8 );
817 t.setEncoding( QTextStream::Latin1 ); 814 t.setEncoding( QTextStream::Latin1 );
818 t <<datastream.latin1(); 815 t <<datastream.latin1();
819 outFile.close(); 816 outFile.close();
820 Ir *ir = new Ir( this ); 817 Ir *ir = new Ir( this );
821 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 818 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
822 ir->send( fileName, description, "text/x-vCard" ); 819 ir->send( fileName, description, "text/x-vCard" );
823 } else { 820 } else {
824 qDebug("Error open temp beam file "); 821 qDebug("Error open temp beam file ");
825 return; 822 return;
826 } 823 }
827#endif 824#endif
828 825
829} 826}
830 827
831void KABCore::beamDone( Ir *ir ) 828void KABCore::beamDone( Ir *ir )
832{ 829{
833#ifndef DESKTOP_VERSION 830#ifndef DESKTOP_VERSION
834 delete ir; 831 delete ir;
835#endif 832#endif
836 topLevelWidget()->raise(); 833 topLevelWidget()->raise();
834 message( i18n("Beaming successful!") );
837} 835}
838 836
839 837
840void KABCore::browse( const QString& url ) 838void KABCore::browse( const QString& url )
841{ 839{
842#ifndef KAB_EMBEDDED 840#ifndef KAB_EMBEDDED
843 kapp->invokeBrowser( url ); 841 kapp->invokeBrowser( url );
844#else //KAB_EMBEDDED 842#else //KAB_EMBEDDED
845 qDebug("KABCore::browse must be fixed"); 843 qDebug("KABCore::browse must be fixed");
846#endif //KAB_EMBEDDED 844#endif //KAB_EMBEDDED
847} 845}
848 846
849void KABCore::selectAllContacts() 847void KABCore::selectAllContacts()
850{ 848{
851 mViewManager->setSelected( QString::null, true ); 849 mViewManager->setSelected( QString::null, true );
852} 850}
853 851
854void KABCore::deleteContacts() 852void KABCore::deleteContacts()
855{ 853{
856 QStringList uidList = mViewManager->selectedUids(); 854 QStringList uidList = mViewManager->selectedUids();
857 deleteContacts( uidList ); 855 deleteContacts( uidList );
858} 856}
859 857
860void KABCore::deleteContacts( const QStringList &uids ) 858void KABCore::deleteContacts( const QStringList &uids )
861{ 859{
862 if ( uids.count() > 0 ) { 860 if ( uids.count() > 0 ) {
863 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 861 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
864 UndoStack::instance()->push( command ); 862 UndoStack::instance()->push( command );
865 RedoStack::instance()->clear(); 863 RedoStack::instance()->clear();
866 864
867 // now if we deleted anything, refresh 865 // now if we deleted anything, refresh
868 setContactSelected( QString::null ); 866 setContactSelected( QString::null );
869 setModified( true ); 867 setModified( true );
870 } 868 }
871} 869}
872 870
873void KABCore::copyContacts() 871void KABCore::copyContacts()
874{ 872{
875 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 873 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
876 874
877 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 875 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
878 876
879 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 877 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
880 878
881 QClipboard *cb = QApplication::clipboard(); 879 QClipboard *cb = QApplication::clipboard();
882 cb->setText( clipText ); 880 cb->setText( clipText );
883} 881}
884 882
885void KABCore::cutContacts() 883void KABCore::cutContacts()
886{ 884{
887 QStringList uidList = mViewManager->selectedUids(); 885 QStringList uidList = mViewManager->selectedUids();
888 886
889//US if ( uidList.size() > 0 ) { 887//US if ( uidList.size() > 0 ) {
890 if ( uidList.count() > 0 ) { 888 if ( uidList.count() > 0 ) {
891 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 889 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
892 UndoStack::instance()->push( command ); 890 UndoStack::instance()->push( command );
893 RedoStack::instance()->clear(); 891 RedoStack::instance()->clear();
894 892
895 setModified( true ); 893 setModified( true );
896 } 894 }
897} 895}
898 896
899void KABCore::pasteContacts() 897void KABCore::pasteContacts()
900{ 898{
901 QClipboard *cb = QApplication::clipboard(); 899 QClipboard *cb = QApplication::clipboard();
902 900
903 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 901 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
904 902
905 pasteContacts( list ); 903 pasteContacts( list );
906} 904}
907 905
908void KABCore::pasteContacts( KABC::Addressee::List &list ) 906void KABCore::pasteContacts( KABC::Addressee::List &list )
909{ 907{
910 KABC::Resource *resource = requestResource( this ); 908 KABC::Resource *resource = requestResource( this );
911 KABC::Addressee::List::Iterator it; 909 KABC::Addressee::List::Iterator it;
912 for ( it = list.begin(); it != list.end(); ++it ) 910 for ( it = list.begin(); it != list.end(); ++it )
913 (*it).setResource( resource ); 911 (*it).setResource( resource );
914 912
915 PwPasteCommand *command = new PwPasteCommand( this, list ); 913 PwPasteCommand *command = new PwPasteCommand( this, list );
916 UndoStack::instance()->push( command ); 914 UndoStack::instance()->push( command );
917 RedoStack::instance()->clear(); 915 RedoStack::instance()->clear();
918 916
919 setModified( true ); 917 setModified( true );
920} 918}
921 919
922void KABCore::setWhoAmI() 920void KABCore::setWhoAmI()
923{ 921{
924 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 922 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
925 923
926 if ( addrList.count() > 1 ) { 924 if ( addrList.count() > 1 ) {
927 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 925 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
928 return; 926 return;
929 } 927 }
930 928
931 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 929 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
932 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 930 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
@@ -2725,157 +2723,152 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2725{ 2723{
2726 2724
2727 //pending prepare addresseeview for output 2725 //pending prepare addresseeview for output
2728 //pending detect, if remote file has REV field. if not switch to external sync 2726 //pending detect, if remote file has REV field. if not switch to external sync
2729 mGlobalSyncMode = SYNC_MODE_NORMAL; 2727 mGlobalSyncMode = SYNC_MODE_NORMAL;
2730 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2728 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2731 2729
2732 AddressBook abLocal(filename,"syncContact"); 2730 AddressBook abLocal(filename,"syncContact");
2733 bool syncOK = false; 2731 bool syncOK = false;
2734 if ( abLocal.load() ) { 2732 if ( abLocal.load() ) {
2735 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2733 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2736 bool external = false; 2734 bool external = false;
2737 bool isXML = false; 2735 bool isXML = false;
2738 if ( filename.right(4) == ".xml") { 2736 if ( filename.right(4) == ".xml") {
2739 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2737 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2740 isXML = true; 2738 isXML = true;
2741 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2739 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2742 } else { 2740 } else {
2743 external = !manager->mIsKapiFile; 2741 external = !manager->mIsKapiFile;
2744 if ( external ) { 2742 if ( external ) {
2745 qDebug("Setting vcf mode to external "); 2743 qDebug("Setting vcf mode to external ");
2746 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2744 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2747 AddressBook::Iterator it; 2745 AddressBook::Iterator it;
2748 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2746 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2749 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2747 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2750 (*it).computeCsum( mCurrentSyncDevice ); 2748 (*it).computeCsum( mCurrentSyncDevice );
2751 } 2749 }
2752 } 2750 }
2753 } 2751 }
2754 //AddressBook::Iterator it; 2752 //AddressBook::Iterator it;
2755 //QStringList vcards; 2753 //QStringList vcards;
2756 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2754 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2757 // qDebug("Name %s ", (*it).familyName().latin1()); 2755 // qDebug("Name %s ", (*it).familyName().latin1());
2758 //} 2756 //}
2759 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2757 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2760 if ( syncOK ) { 2758 if ( syncOK ) {
2761 if ( syncManager->mWriteBackFile ) 2759 if ( syncManager->mWriteBackFile )
2762 { 2760 {
2763 if ( external ) 2761 if ( external )
2764 abLocal.removeSyncAddressees( !isXML); 2762 abLocal.removeSyncAddressees( !isXML);
2765 qDebug("Saving remote AB "); 2763 qDebug("Saving remote AB ");
2766 if ( ! abLocal.saveAB()) 2764 if ( ! abLocal.saveAB())
2767 qDebug("Error writing back AB to file "); 2765 qDebug("Error writing back AB to file ");
2768 if ( isXML ) { 2766 if ( isXML ) {
2769 // afterwrite processing 2767 // afterwrite processing
2770 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2768 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2771 } 2769 }
2772 } 2770 }
2773 } 2771 }
2774 setModified(); 2772 setModified();
2775 2773
2776 } 2774 }
2777 if ( syncOK ) 2775 if ( syncOK )
2778 mViewManager->refreshView(); 2776 mViewManager->refreshView();
2779 return syncOK; 2777 return syncOK;
2780 2778
2781} 2779}
2782 2780
2783 2781
2784//this is a overwritten callbackmethods from the syncinterface 2782//this is a overwritten callbackmethods from the syncinterface
2785bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2783bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2786{ 2784{
2787 if ( resource == "phone" ) 2785 if ( resource == "phone" )
2788 return syncPhone(); 2786 return syncPhone();
2789 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2787 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2790 2788
2791 AddressBook abLocal( resource,"syncContact"); 2789 AddressBook abLocal( resource,"syncContact");
2792 bool syncOK = false; 2790 bool syncOK = false;
2793 if ( abLocal.load() ) { 2791 if ( abLocal.load() ) {
2794 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2792 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2795 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2793 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2796 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2794 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2797 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2795 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2798 if ( syncOK ) { 2796 if ( syncOK ) {
2799 if ( syncManager->mWriteBackFile ) { 2797 if ( syncManager->mWriteBackFile ) {
2800 abLocal.removeSyncAddressees( false ); 2798 abLocal.removeSyncAddressees( false );
2801 abLocal.saveAB(); 2799 abLocal.saveAB();
2802 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2800 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2803 } 2801 }
2804 } 2802 }
2805 setModified(); 2803 setModified();
2806 } 2804 }
2807 if ( syncOK ) 2805 if ( syncOK )
2808 mViewManager->refreshView(); 2806 mViewManager->refreshView();
2809 return syncOK; 2807 return syncOK;
2810 2808
2811} 2809}
2812void KABCore::message( QString m ) 2810void KABCore::message( QString m )
2813{ 2811{
2814 2812
2815 topLevelWidget()->setCaption( m ); 2813 topLevelWidget()->setCaption( m );
2816 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2814 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2817} 2815}
2818bool KABCore::syncPhone() 2816bool KABCore::syncPhone()
2819{ 2817{
2820 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2818 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2821 QString fileName; 2819 QString fileName = getPhoneFile();
2822#ifdef _WIN32_
2823 fileName = locateLocal("tmp", "phonefile.vcf");
2824#else
2825 fileName = "/tmp/phonefile.vcf";
2826#endif
2827 if ( !PhoneAccess::readFromPhone( fileName) ) { 2820 if ( !PhoneAccess::readFromPhone( fileName) ) {
2828 message(i18n("Phone access failed!")); 2821 message(i18n("Phone access failed!"));
2829 return false; 2822 return false;
2830 } 2823 }
2831 AddressBook abLocal( fileName,"syncContact"); 2824 AddressBook abLocal( fileName,"syncContact");
2832 bool syncOK = false; 2825 bool syncOK = false;
2833 { 2826 {
2834 abLocal.importFromFile( fileName ); 2827 abLocal.importFromFile( fileName );
2835 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2828 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2836 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2829 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2837 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2830 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2838 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2831 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2839 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2832 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2840 if ( syncOK ) { 2833 if ( syncOK ) {
2841 if ( syncManager->mWriteBackFile ) { 2834 if ( syncManager->mWriteBackFile ) {
2842 abLocal.removeSyncAddressees( true ); 2835 abLocal.removeSyncAddressees( true );
2843 abLocal.saveABphone( fileName ); 2836 abLocal.saveABphone( fileName );
2844 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2837 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2845 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2838 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2846 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2839 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2847 } 2840 }
2848 } 2841 }
2849 setModified(); 2842 setModified();
2850 } 2843 }
2851 if ( syncOK ) 2844 if ( syncOK )
2852 mViewManager->refreshView(); 2845 mViewManager->refreshView();
2853 return syncOK; 2846 return syncOK;
2854} 2847}
2855void KABCore::getFile( bool success ) 2848void KABCore::getFile( bool success )
2856{ 2849{
2857 if ( ! success ) { 2850 if ( ! success ) {
2858 message( i18n("Error receiving file. Nothing changed!") ); 2851 message( i18n("Error receiving file. Nothing changed!") );
2859 return; 2852 return;
2860 } 2853 }
2861 mAddressBook->importFromFile( sentSyncFile() , false, true ); 2854 mAddressBook->importFromFile( sentSyncFile() , false, true );
2862 message( i18n("Pi-Sync successful!") ); 2855 message( i18n("Pi-Sync successful!") );
2863 mViewManager->refreshView(); 2856 mViewManager->refreshView();
2864} 2857}
2865void KABCore::syncFileRequest() 2858void KABCore::syncFileRequest()
2866{ 2859{
2867 mAddressBook->export2File( sentSyncFile() ); 2860 mAddressBook->export2File( sentSyncFile() );
2868} 2861}
2869QString KABCore::sentSyncFile() 2862QString KABCore::sentSyncFile()
2870{ 2863{
2871#ifdef _WIN32_ 2864#ifdef _WIN32_
2872 return locateLocal( "tmp", "copysyncab.vcf" ); 2865 return locateLocal( "tmp", "copysyncab.vcf" );
2873#else 2866#else
2874 return QString( "/tmp/copysyncab.vcf" ); 2867 return QString( "/tmp/copysyncab.vcf" );
2875#endif 2868#endif
2876} 2869}
2877 2870
2878void KABCore::setCaptionBack() 2871void KABCore::setCaptionBack()
2879{ 2872{
2880 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2873 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2881} 2874}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 3c33923..5871d39 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -55,192 +55,193 @@ class XXPortManager;
55class JumpButtonBar; 55class JumpButtonBar;
56class IncSearchWidget; 56class IncSearchWidget;
57class KDGanttMinimizeSplitter; 57class KDGanttMinimizeSplitter;
58class KAction; 58class KAction;
59class KActionCollection; 59class KActionCollection;
60class KToggleAction; 60class KToggleAction;
61class KSyncProfile; 61class KSyncProfile;
62 62
63class QAction; 63class QAction;
64class QMenuBar; 64class QMenuBar;
65class QSplitter; 65class QSplitter;
66class ViewContainer; 66class ViewContainer;
67class ViewManager; 67class ViewManager;
68class AddresseeEditorDialog; 68class AddresseeEditorDialog;
69class Ir; 69class Ir;
70 70
71class KABCore : public QWidget, public KSyncInterface 71class KABCore : public QWidget, public KSyncInterface
72{ 72{
73 Q_OBJECT 73 Q_OBJECT
74 74
75 public: 75 public:
76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
77 77
78 78
79 ~KABCore(); 79 ~KABCore();
80 80
81 81
82#ifdef KAB_EMBEDDED 82#ifdef KAB_EMBEDDED
83 //US added functionality 83 //US added functionality
84 QPopupMenu* getViewMenu() {return viewMenu;} 84 QPopupMenu* getViewMenu() {return viewMenu;}
85 QPopupMenu* getFilterMenu() {return filterMenu;} 85 QPopupMenu* getFilterMenu() {return filterMenu;}
86 QPopupMenu* getSettingsMenu() {return settingsMenu;} 86 QPopupMenu* getSettingsMenu() {return settingsMenu;}
87 void addActionsManually(); 87 void addActionsManually();
88#endif //KAB_EMBEDDED 88#endif //KAB_EMBEDDED
89 /** 89 /**
90 Restores the global settings. 90 Restores the global settings.
91 */ 91 */
92 void restoreSettings(); 92 void restoreSettings();
93 93
94 /** 94 /**
95 Saves the global settings. 95 Saves the global settings.
96 */ 96 */
97 void saveSettings(); 97 void saveSettings();
98 98
99 /** 99 /**
100 Returns a pointer to the StdAddressBook of the application. 100 Returns a pointer to the StdAddressBook of the application.
101 */ 101 */
102 KABC::AddressBook *addressBook() const; 102 KABC::AddressBook *addressBook() const;
103 103
104 /** 104 /**
105 Returns a pointer to the KConfig object of the application. 105 Returns a pointer to the KConfig object of the application.
106 */ 106 */
107 static KConfig *config(); 107 static KConfig *config();
108 108
109 /** 109 /**
110 Returns a pointer to the global KActionCollection object. So 110 Returns a pointer to the global KActionCollection object. So
111 other classes can register their actions easily. 111 other classes can register their actions easily.
112 */ 112 */
113 KActionCollection *actionCollection() const; 113 KActionCollection *actionCollection() const;
114 114
115 /** 115 /**
116 Returns the current search field of the Incremental Search Widget. 116 Returns the current search field of the Incremental Search Widget.
117 */ 117 */
118 KABC::Field *currentSearchField() const; 118 KABC::Field *currentSearchField() const;
119 119
120 /** 120 /**
121 Returns the uid list of the currently selected contacts. 121 Returns the uid list of the currently selected contacts.
122 */ 122 */
123 QStringList selectedUIDs() const; 123 QStringList selectedUIDs() const;
124 124
125 /** 125 /**
126 Displays the ResourceSelectDialog and returns the selected 126 Displays the ResourceSelectDialog and returns the selected
127 resource or a null pointer if no resource was selected by 127 resource or a null pointer if no resource was selected by
128 the user. 128 the user.
129 */ 129 */
130 KABC::Resource *requestResource( QWidget *parent ); 130 KABC::Resource *requestResource( QWidget *parent );
131 131
132#ifndef KAB_EMBEDDED 132#ifndef KAB_EMBEDDED
133 static KAboutData *createAboutData(); 133 static KAboutData *createAboutData();
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 135
136#ifdef KAB_EMBEDDED 136#ifdef KAB_EMBEDDED
137 inline QPopupMenu* getImportMenu() { return ImportMenu;} 137 inline QPopupMenu* getImportMenu() { return ImportMenu;}
138 inline QPopupMenu* getExportMenu() { return ExportMenu;} 138 inline QPopupMenu* getExportMenu() { return ExportMenu;}
139#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
140 140
141 public slots: 141 public slots:
142#ifdef KAB_EMBEDDED 142#ifdef KAB_EMBEDDED
143 void createAboutData(); 143 void createAboutData();
144#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
145 145
146 void statusMessage(QString, int time = 0 ); 146 void statusMessage(QString, int time = 0 );
147 void showLicence(); 147 void showLicence();
148 void faq(); 148 void faq();
149 void whatsnew() ; 149 void whatsnew() ;
150 void synchowto() ; 150 void synchowto() ;
151 void writeToPhone();
151 152
152 /** 153 /**
153 Is called whenever a contact is selected in the view. 154 Is called whenever a contact is selected in the view.
154 */ 155 */
155 void setContactSelected( const QString &uid ); 156 void setContactSelected( const QString &uid );
156 157
157 /** 158 /**
158 Opens the preferred mail composer with all selected contacts as 159 Opens the preferred mail composer with all selected contacts as
159 arguments. 160 arguments.
160 */ 161 */
161 void sendMail(); 162 void sendMail();
162 163
163 /** 164 /**
164 Opens the preferred mail composer with the given contacts as 165 Opens the preferred mail composer with the given contacts as
165 arguments. 166 arguments.
166 */ 167 */
167 void sendMail( const QString& email ); 168 void sendMail( const QString& email );
168 169
169 170
170 void mailVCard(); 171 void mailVCard();
171 void mailVCard(const QStringList& uids); 172 void mailVCard(const QStringList& uids);
172 173
173 /** 174 /**
174 Beams the "WhoAmI contact. 175 Beams the "WhoAmI contact.
175 */ 176 */
176 void beamMySelf(); 177 void beamMySelf();
177 178
178 void beamVCard(); 179 void beamVCard();
179 void export2phone(); 180 void export2phone();
180 void beamVCard(const QStringList& uids); 181 void beamVCard(const QStringList& uids);
181 void beamDone( Ir *ir ); 182 void beamDone( Ir *ir );
182 183
183 184
184 /** 185 /**
185 Starts the preferred web browser with the given URL as argument. 186 Starts the preferred web browser with the given URL as argument.
186 */ 187 */
187 void browse( const QString& url ); 188 void browse( const QString& url );
188 189
189 /** 190 /**
190 Select all contacts in the view. 191 Select all contacts in the view.
191 */ 192 */
192 void selectAllContacts(); 193 void selectAllContacts();
193 194
194 /** 195 /**
195 Deletes all selected contacts from the address book. 196 Deletes all selected contacts from the address book.
196 */ 197 */
197 void deleteContacts(); 198 void deleteContacts();
198 199
199 /** 200 /**
200 Deletes given contacts from the address book. 201 Deletes given contacts from the address book.
201 202
202 @param uids The uids of the contacts, which shall be deleted. 203 @param uids The uids of the contacts, which shall be deleted.
203 */ 204 */
204 void deleteContacts( const QStringList &uids ); 205 void deleteContacts( const QStringList &uids );
205 206
206 /** 207 /**
207 Copys the selected contacts into clipboard for later pasting. 208 Copys the selected contacts into clipboard for later pasting.
208 */ 209 */
209 void copyContacts(); 210 void copyContacts();
210 211
211 /** 212 /**
212 Cuts the selected contacts and stores them for later pasting. 213 Cuts the selected contacts and stores them for later pasting.
213 */ 214 */
214 void cutContacts(); 215 void cutContacts();
215 216
216 /** 217 /**
217 Paste contacts from clipboard into the address book. 218 Paste contacts from clipboard into the address book.
218 */ 219 */
219 void pasteContacts(); 220 void pasteContacts();
220 221
221 /** 222 /**
222 Paste given contacts into the address book. 223 Paste given contacts into the address book.
223 224
224 @param list The list of addressee, which shall be pasted. 225 @param list The list of addressee, which shall be pasted.
225 */ 226 */
226 void pasteContacts( KABC::Addressee::List &list ); 227 void pasteContacts( KABC::Addressee::List &list );
227 228
228 /** 229 /**
229 Sets the whoAmI contact, that is used by many other programs to 230 Sets the whoAmI contact, that is used by many other programs to
230 get personal information about the current user. 231 get personal information about the current user.
231 */ 232 */
232 void setWhoAmI(); 233 void setWhoAmI();
233 234
234 /** 235 /**
235 Displays the category dialog and applies the result to all 236 Displays the category dialog and applies the result to all
236 selected contacts. 237 selected contacts.
237 */ 238 */
238 void setCategories(); 239 void setCategories();
239 240
240 /** 241 /**
241 Sets the field list of the Incremental Search Widget. 242 Sets the field list of the Incremental Search Widget.
242 */ 243 */
243 void setSearchFields( const KABC::Field::List &fields ); 244 void setSearchFields( const KABC::Field::List &fields );
244 245
245 /** 246 /**
246 Search with the current search field for a contact, that matches 247 Search with the current search field for a contact, that matches
@@ -278,192 +279,193 @@ class KABCore : public QWidget, public KSyncInterface
278 */ 279 */
279 void addEmail( QString addr ); 280 void addEmail( QString addr );
280 void importVCard( const KURL& url, bool showPreview ); 281 void importVCard( const KURL& url, bool showPreview );
281 void importVCard( const QString& vCard, bool showPreview ); 282 void importVCard( const QString& vCard, bool showPreview );
282 void newContact(); 283 void newContact();
283 QString getNameByPhone( const QString& phone ); 284 QString getNameByPhone( const QString& phone );
284 /** 285 /**
285 END DCOP METHODS 286 END DCOP METHODS
286 */ 287 */
287 288
288 /** 289 /**
289 Saves the contents of the AddressBook back to disk. 290 Saves the contents of the AddressBook back to disk.
290 */ 291 */
291 void save(); 292 void save();
292 293
293 /** 294 /**
294 Undos the last command using the undo stack. 295 Undos the last command using the undo stack.
295 */ 296 */
296 void undo(); 297 void undo();
297 298
298 /** 299 /**
299 Redos the last command that was undone, using the redo stack. 300 Redos the last command that was undone, using the redo stack.
300 */ 301 */
301 void redo(); 302 void redo();
302 303
303 /** 304 /**
304 Shows the edit dialog for the given uid. If the uid is QString::null, 305 Shows the edit dialog for the given uid. If the uid is QString::null,
305 the method will try to find a selected addressee in the view. 306 the method will try to find a selected addressee in the view.
306 */ 307 */
307 void editContact( const QString &uid /*US = QString::null*/ ); 308 void editContact( const QString &uid /*US = QString::null*/ );
308//US added a second method without defaultparameter 309//US added a second method without defaultparameter
309 void editContact2(); 310 void editContact2();
310 311
311 /** 312 /**
312 Shows or edits the detail view for the given uid. If the uid is QString::null, 313 Shows or edits the detail view for the given uid. If the uid is QString::null,
313 the method will try to find a selected addressee in the view. 314 the method will try to find a selected addressee in the view.
314 */ 315 */
315 void executeContact( const QString &uid /*US = QString::null*/ ); 316 void executeContact( const QString &uid /*US = QString::null*/ );
316 317
317 /** 318 /**
318 Launches the configuration dialog. 319 Launches the configuration dialog.
319 */ 320 */
320 void openConfigDialog(); 321 void openConfigDialog();
321 322
322 /** 323 /**
323 Launches the ldap search dialog. 324 Launches the ldap search dialog.
324 */ 325 */
325 void openLDAPDialog(); 326 void openLDAPDialog();
326 327
327 /** 328 /**
328 Creates a KAddressBookPrinter, which will display the print 329 Creates a KAddressBookPrinter, which will display the print
329 dialog and do the printing. 330 dialog and do the printing.
330 */ 331 */
331 void print(); 332 void print();
332 333
333 /** 334 /**
334 Registers a new GUI client, so plugins can register its actions. 335 Registers a new GUI client, so plugins can register its actions.
335 */ 336 */
336 void addGUIClient( KXMLGUIClient *client ); 337 void addGUIClient( KXMLGUIClient *client );
337 338
338 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 339 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
339 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 340 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
340 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 341 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
341 342
342 343
343 signals: 344 signals:
344 void contactSelected( const QString &name ); 345 void contactSelected( const QString &name );
345 void contactSelected( const QPixmap &pixmap ); 346 void contactSelected( const QPixmap &pixmap );
346 public slots: 347 public slots:
347 void recieve(QString cmsg ); 348 void recieve(QString cmsg );
348 void getFile( bool success ); 349 void getFile( bool success );
349 void syncFileRequest(); 350 void syncFileRequest();
350 void setDetailsVisible( bool visible ); 351 void setDetailsVisible( bool visible );
351 void setDetailsToState(); 352 void setDetailsToState();
352 // void slotSyncMenu( int ); 353 // void slotSyncMenu( int );
353 private slots: 354 private slots:
354 void setJumpButtonBarVisible( bool visible ); 355 void setJumpButtonBarVisible( bool visible );
355 void setCaptionBack(); 356 void setCaptionBack();
356 void importFromOL(); 357 void importFromOL();
357 void extensionModified( const KABC::Addressee::List &list ); 358 void extensionModified( const KABC::Addressee::List &list );
358 void extensionChanged( int id ); 359 void extensionChanged( int id );
359 void clipboardDataChanged(); 360 void clipboardDataChanged();
360 void updateActionMenu(); 361 void updateActionMenu();
361 void configureKeyBindings(); 362 void configureKeyBindings();
362 void removeVoice(); 363 void removeVoice();
363#ifdef KAB_EMBEDDED 364#ifdef KAB_EMBEDDED
364 void configureResources(); 365 void configureResources();
365#endif //KAB_EMBEDDED 366#endif //KAB_EMBEDDED
366 367
367 void slotEditorDestroyed( const QString &uid ); 368 void slotEditorDestroyed( const QString &uid );
368 void configurationChanged(); 369 void configurationChanged();
369 void addressBookChanged(); 370 void addressBookChanged();
370 371
371 private: 372 private:
372 void initGUI(); 373 void initGUI();
373 void initActions(); 374 void initActions();
375 QString getPhoneFile();
374 376
375 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 377 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
376 const char *name = 0 ); 378 const char *name = 0 );
377 379
378 KXMLGUIClient *mGUIClient; 380 KXMLGUIClient *mGUIClient;
379 381
380 KABC::AddressBook *mAddressBook; 382 KABC::AddressBook *mAddressBook;
381 383
382 ViewManager *mViewManager; 384 ViewManager *mViewManager;
383 // QSplitter *mDetailsSplitter; 385 // QSplitter *mDetailsSplitter;
384 KDGanttMinimizeSplitter *mExtensionBarSplitter; 386 KDGanttMinimizeSplitter *mExtensionBarSplitter;
385 ViewContainer *mDetails; 387 ViewContainer *mDetails;
386 KDGanttMinimizeSplitter* mMiniSplitter; 388 KDGanttMinimizeSplitter* mMiniSplitter;
387 XXPortManager *mXXPortManager; 389 XXPortManager *mXXPortManager;
388 JumpButtonBar *mJumpButtonBar; 390 JumpButtonBar *mJumpButtonBar;
389 IncSearchWidget *mIncSearchWidget; 391 IncSearchWidget *mIncSearchWidget;
390 ExtensionManager *mExtensionManager; 392 ExtensionManager *mExtensionManager;
391 393
392 KCMultiDialog *mConfigureDialog; 394 KCMultiDialog *mConfigureDialog;
393 395
394#ifndef KAB_EMBEDDED 396#ifndef KAB_EMBEDDED
395 LDAPSearchDialog *mLdapSearchDialog; 397 LDAPSearchDialog *mLdapSearchDialog;
396#endif //KAB_EMBEDDED 398#endif //KAB_EMBEDDED
397 // QDict<AddresseeEditorDialog> mEditorDict; 399 // QDict<AddresseeEditorDialog> mEditorDict;
398 AddresseeEditorDialog *mEditorDialog; 400 AddresseeEditorDialog *mEditorDialog;
399 bool mReadWrite; 401 bool mReadWrite;
400 bool mModified; 402 bool mModified;
401 bool mIsPart; 403 bool mIsPart;
402 bool mMultipleViewsAtOnce; 404 bool mMultipleViewsAtOnce;
403 405
404 406
405 //US file menu 407 //US file menu
406 KAction *mActionMail; 408 KAction *mActionMail;
407 KAction *mActionBeam; 409 KAction *mActionBeam;
408 KAction *mActionExport2phone; 410 KAction *mActionExport2phone;
409 KAction* mActionPrint; 411 KAction* mActionPrint;
410 KAction* mActionNewContact; 412 KAction* mActionNewContact;
411 KAction *mActionSave; 413 KAction *mActionSave;
412 KAction *mActionEditAddressee; 414 KAction *mActionEditAddressee;
413 KAction *mActionMailVCard; 415 KAction *mActionMailVCard;
414 KAction *mActionBeamVCard; 416 KAction *mActionBeamVCard;
415 417
416 KAction *mActionQuit; 418 KAction *mActionQuit;
417 419
418 //US edit menu 420 //US edit menu
419 KAction *mActionCopy; 421 KAction *mActionCopy;
420 KAction *mActionCut; 422 KAction *mActionCut;
421 KAction *mActionPaste; 423 KAction *mActionPaste;
422 KAction *mActionSelectAll; 424 KAction *mActionSelectAll;
423 KAction *mActionUndo; 425 KAction *mActionUndo;
424 KAction *mActionRedo; 426 KAction *mActionRedo;
425 KAction *mActionDelete; 427 KAction *mActionDelete;
426 428
427 //US settings menu 429 //US settings menu
428 KAction *mActionConfigResources; 430 KAction *mActionConfigResources;
429 KAction *mActionConfigKAddressbook; 431 KAction *mActionConfigKAddressbook;
430 KAction *mActionConfigShortcuts; 432 KAction *mActionConfigShortcuts;
431 KAction *mActionConfigureToolbars; 433 KAction *mActionConfigureToolbars;
432 KAction *mActionKeyBindings; 434 KAction *mActionKeyBindings;
433 KToggleAction *mActionJumpBar; 435 KToggleAction *mActionJumpBar;
434 KToggleAction *mActionDetails; 436 KToggleAction *mActionDetails;
435 KAction *mActionWhoAmI; 437 KAction *mActionWhoAmI;
436 KAction *mActionCategories; 438 KAction *mActionCategories;
437 KAction *mActionAboutKAddressbook; 439 KAction *mActionAboutKAddressbook;
438 KAction *mActionLicence; 440 KAction *mActionLicence;
439 KAction *mActionFaq; 441 KAction *mActionFaq;
440 KAction *mActionWN; 442 KAction *mActionWN;
441 KAction *mActionSyncHowto; 443 KAction *mActionSyncHowto;
442 444
443 KAction *mActionDeleteView; 445 KAction *mActionDeleteView;
444 446
445 QPopupMenu *viewMenu; 447 QPopupMenu *viewMenu;
446 QPopupMenu *filterMenu; 448 QPopupMenu *filterMenu;
447 QPopupMenu *settingsMenu; 449 QPopupMenu *settingsMenu;
448 QPopupMenu *changeMenu; 450 QPopupMenu *changeMenu;
449//US QAction *mActionSave; 451//US QAction *mActionSave;
450 QPopupMenu *ImportMenu; 452 QPopupMenu *ImportMenu;
451 QPopupMenu *ExportMenu; 453 QPopupMenu *ExportMenu;
452 //LR additional methods 454 //LR additional methods
453 KAction *mActionRemoveVoice; 455 KAction *mActionRemoveVoice;
454 KAction * mActionImportOL; 456 KAction * mActionImportOL;
455 457
456#ifndef KAB_EMBEDDED 458#ifndef KAB_EMBEDDED
457 KAddressBookService *mAddressBookService; 459 KAddressBookService *mAddressBookService;
458#endif //KAB_EMBEDDED 460#endif //KAB_EMBEDDED
459 461
460 class KABCorePrivate; 462 class KABCorePrivate;
461 KABCorePrivate *d; 463 KABCorePrivate *d;
462 //US bool mBlockSaveFlag; 464 //US bool mBlockSaveFlag;
463 465
464#ifdef KAB_EMBEDDED 466#ifdef KAB_EMBEDDED
465 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 467 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
466#endif //KAB_EMBEDDED 468#endif //KAB_EMBEDDED
467 469
468 //this are the overwritten callbackmethods from the syncinterface 470 //this are the overwritten callbackmethods from the syncinterface
469 virtual bool sync(KSyncManager* manager, QString filename, int mode); 471 virtual bool sync(KSyncManager* manager, QString filename, int mode);