author | zautrix <zautrix> | 2004-10-08 20:03:23 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-08 20:03:23 (UTC) |
commit | 10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34 (patch) (unidiff) | |
tree | 3105b985a9dbedd31dff52e14fe667eeff4f9ff4 /kaddressbook | |
parent | 13bd085e06b76228321f5a004759fcdf19cca711 (diff) | |
download | kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.zip kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.gz kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.bz2 |
added contact phone support
-rw-r--r-- | kaddressbook/kabcore.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index c5406bf..939296f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -654,117 +654,132 @@ void KABCore::beamMySelf() | |||
654 | uids << a.uid(); | 654 | uids << a.uid(); |
655 | 655 | ||
656 | beamVCard(uids); | 656 | beamVCard(uids); |
657 | } else { | 657 | } else { |
658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
659 | 659 | ||
660 | 660 | ||
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | void KABCore::export2phone() | 664 | void KABCore::export2phone() |
665 | { | 665 | { |
666 | 666 | ||
667 | KAex2phonePrefs ex2phone; | 667 | KAex2phonePrefs ex2phone; |
668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
671 | 671 | ||
672 | if ( !ex2phone.exec() ) { | 672 | if ( !ex2phone.exec() ) { |
673 | return; | 673 | return; |
674 | } | 674 | } |
675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
678 | 678 | ||
679 | 679 | ||
680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
683 | 683 | ||
684 | QStringList uids = mViewManager->selectedUids(); | 684 | QStringList uids = mViewManager->selectedUids(); |
685 | if ( uids.isEmpty() ) | 685 | if ( uids.isEmpty() ) |
686 | return; | 686 | return; |
687 | 687 | ||
688 | #ifdef _WIN32_ | 688 | #ifdef _WIN32_ |
689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); | 689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); |
690 | #else | 690 | #else |
691 | QString fileName = "/tmp/kdepimtemp.vcf"; | 691 | QString fileName = "/tmp/kdepimtemp.vcf"; |
692 | #endif | 692 | #endif |
693 | 693 | ||
694 | KABC::VCardConverter converter; | 694 | KABC::VCardConverter converter; |
695 | QString description; | 695 | QString description; |
696 | QString datastream; | 696 | QString datastream; |
697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
698 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 698 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
699 | 699 | ||
700 | if ( a.isEmpty() ) | 700 | if ( a.isEmpty() ) |
701 | continue; | 701 | continue; |
702 | a.simplifyEmails(); | ||
703 | a.simplifyPhoneNumbers(); | ||
704 | a.simplifyPhoneNumberTypes(); | ||
702 | 705 | ||
703 | if (description.isEmpty()) | 706 | if (description.isEmpty()) |
704 | description = a.formattedName(); | 707 | description = a.formattedName(); |
705 | |||
706 | QString vcard; | 708 | QString vcard; |
709 | QString vcardnew; | ||
707 | converter.addresseeToVCard( a, vcard ); | 710 | converter.addresseeToVCard( a, vcard ); |
708 | int start = 0; | 711 | int start = 0; |
709 | int next; | 712 | int next; |
710 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 713 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
711 | int semi = vcard.find(";", next); | 714 | int semi = vcard.find(";", next); |
712 | int dopp = vcard.find(":", next); | 715 | int dopp = vcard.find(":", next); |
713 | int sep; | 716 | int sep; |
714 | if ( semi < dopp && semi >= 0 ) | 717 | if ( semi < dopp && semi >= 0 ) |
715 | sep = semi ; | 718 | sep = semi ; |
716 | else | 719 | else |
717 | sep = dopp; | 720 | sep = dopp; |
718 | datastream +=vcard.mid( start, next - start); | 721 | vcardnew +=vcard.mid( start, next - start); |
719 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 722 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
720 | start = sep; | 723 | start = sep; |
721 | } | 724 | } |
722 | datastream += vcard.mid( start,vcard.length() ); | 725 | vcardnew += vcard.mid( start,vcard.length() ); |
726 | vcard = ""; | ||
727 | start = 0; | ||
728 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | ||
729 | int sep = vcardnew.find(":", next); | ||
730 | vcard +=vcardnew.mid( start, next - start+3); | ||
731 | start = sep; | ||
732 | } | ||
733 | vcard += vcardnew.mid( start,vcardnew.length() ); | ||
734 | vcard.replace ( QRegExp(";;;") , "" ); | ||
735 | vcard.replace ( QRegExp(";;") , "" ); | ||
736 | datastream += vcard; | ||
737 | |||
723 | } | 738 | } |
724 | QFile outFile(fileName); | 739 | QFile outFile(fileName); |
725 | if ( outFile.open(IO_WriteOnly) ) { | 740 | if ( outFile.open(IO_WriteOnly) ) { |
726 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 741 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
727 | QTextStream t( &outFile ); // use a text stream | 742 | QTextStream t( &outFile ); // use a text stream |
728 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 743 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
729 | t <<datastream; | 744 | t <<datastream; |
730 | outFile.close(); | 745 | outFile.close(); |
731 | if ( PhoneAccess::writeToPhone( fileName ) ) | 746 | if ( PhoneAccess::writeToPhone( fileName ) ) |
732 | qDebug("Export okay "); | 747 | qDebug("Export okay "); |
733 | else | 748 | else |
734 | qDebug("Error export contacts "); | 749 | qDebug("Error export contacts "); |
735 | 750 | ||
736 | } else { | 751 | } else { |
737 | qDebug("Error open temp file "); | 752 | qDebug("Error open temp file "); |
738 | return; | 753 | return; |
739 | } | 754 | } |
740 | 755 | ||
741 | 756 | ||
742 | #if 0 | 757 | #if 0 |
743 | 758 | ||
744 | setCaption( i18n("Writing to phone...")); | 759 | setCaption( i18n("Writing to phone...")); |
745 | if ( PhoneFormat::writeToPhone( cal ) ) | 760 | if ( PhoneFormat::writeToPhone( cal ) ) |
746 | setCaption( i18n("Export to phone successful!")); | 761 | setCaption( i18n("Export to phone successful!")); |
747 | else | 762 | else |
748 | setCaption( i18n("Error exporting to phone!")); | 763 | setCaption( i18n("Error exporting to phone!")); |
749 | #endif | 764 | #endif |
750 | 765 | ||
751 | 766 | ||
752 | } | 767 | } |
753 | void KABCore::beamVCard() | 768 | void KABCore::beamVCard() |
754 | { | 769 | { |
755 | QStringList uids = mViewManager->selectedUids(); | 770 | QStringList uids = mViewManager->selectedUids(); |
756 | if ( !uids.isEmpty() ) | 771 | if ( !uids.isEmpty() ) |
757 | beamVCard( uids ); | 772 | beamVCard( uids ); |
758 | } | 773 | } |
759 | 774 | ||
760 | 775 | ||
761 | void KABCore::beamVCard(const QStringList& uids) | 776 | void KABCore::beamVCard(const QStringList& uids) |
762 | { | 777 | { |
763 | /*US | 778 | /*US |
764 | QString beamFilename; | 779 | QString beamFilename; |
765 | Opie::OPimContact c; | 780 | Opie::OPimContact c; |
766 | if ( actionPersonal->isOn() ) { | 781 | if ( actionPersonal->isOn() ) { |
767 | beamFilename = addressbookPersonalVCardName(); | 782 | beamFilename = addressbookPersonalVCardName(); |
768 | if ( !QFile::exists( beamFilename ) ) | 783 | if ( !QFile::exists( beamFilename ) ) |
769 | return; // can't beam a non-existent file | 784 | return; // can't beam a non-existent file |
770 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 785 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |