summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp23
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
@@ -690,45 +690,60 @@ void KABCore::export2phone()
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 ");