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 | |||
@@ -678,69 +678,84 @@ void KABCore::export2phone() | |||
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!")); |